-
Notifications
You must be signed in to change notification settings - Fork 586
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Check that the alphabet argument to text() is a sequence of unicode characters #1329
Comments
|
@Zac-HD I would like to work on this issue. I guess I understand most of the things, except |
|
Because >>> text(['abc'], min_size=2, max_size=2).example()
'abcabc'
>>> len(_)
6 |
|
@Zac-HD got it, so basically alphabet must be sequence of single characters. |
|
@Zac-HD if not isinstance(alphabet, Sequence):
note_deprecation(...)
alphabet = list(alphabet)If I assume that above check is for catching things like like I have more or less created test cases for all scenario, except if PY2:
non_unicode = [c for c in alphabet if not isinstance(c, text_type)]
if non_unicode:
note_deprecationShall I have conditional test case for PY2? |
|
The main purpose is actually to catch unordered collections, like You can put a Python2-specific test in To test a deprecated thing, write a test that passes but ignores the deprecation, then add the |
Close HypothesisWorks#1329 fix lint issues
Close HypothesisWorks#1329 fix lint issues refactor code as per review comments. add RELEASE.rst
Close HypothesisWorks#1329 fix lint issues refactor code as per review comments. add RELEASE.rst fix check-formats travis job.
Close HypothesisWorks#1329 fix lint issues refactor code as per review comments. add RELEASE.rst fix check-formats travis job. fix lint issues after refactoring.
Close HypothesisWorks#1329 fix lint issues refactor code as per review comments. add RELEASE.rst fix check-format issues.
Close HypothesisWorks#1329 fix lint issues refactor code as per review comments. add RELEASE.rst fix check-format issues.
Close HypothesisWorks#1329 fix lint issues refactor code as per review comments. add RELEASE.rst fix failing test cases due to unicode warning. fix mypy error.
Close HypothesisWorks#1329 fix lint issues refactor code as per review comments. add RELEASE.rst fix failing test cases due to unicode warning. fix mypy error.
The
alphabetargument totext()may be None, a strategy for generating unicode characters (typically thecharacters()strategy), or a sequence of unicode characters (possibly provided as a string).However, there is very little validation of the sequence-of-characters form. We should deprecate use of non-sequence collections (as for
sampled_from, hash randomisation breaks reproducibility), deprecate non-length-one elements (iealphabet=['a', 'bc']is bad), and error on non-string types instead of coercing them to text. Python2strshould emit a deprecation warning, since this is probably a common misuse and usually works.A fixed implementation might look like
Note that all error messages should show the repr of each 'bad' value, explain why it is bad, and usually suggest what the user should do instead. Filling that out, plus tests, would be a fantastic contribution.
If you'd like to work on this, let me know - I can lend a hand and also ensure that only one person works on any issue at a given time 😄
The text was updated successfully, but these errors were encountered: