-
Notifications
You must be signed in to change notification settings - Fork 575
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
Minor fixes #3688
Minor fixes #3688
Changes from all commits
4a879bb
98a4361
ea93372
9bc5574
f60eee2
063b6cf
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -284,6 +284,7 @@ def biased_coin( | |
# (see https://bugs.python.org/issue2506), coverage incorrectly | ||
# thinks that this condition is always true. You can trivially | ||
# check by adding `else: assert False` and running the tests. | ||
# Note: Fixed in both CPython and PyPy 3.10, with PEP 626 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Oh, nice! Since we now only support Python >= 3.8, and run coverage jobs on 3.10, let's just delete the pragma and this whole comment |
||
data.draw_bits(bits, forced=int(result)) | ||
break | ||
data.stop_example() | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -335,10 +335,10 @@ def extract_lambda_source(f): | |
break | ||
except SyntaxError: | ||
continue | ||
if tree is None and source.startswith("@"): | ||
# This will always eventually find a valid expression because | ||
# the decorator must be a valid Python function call, so will | ||
# eventually be syntactically valid and break out of the loop. | ||
if tree is None and source and source[0] in ["@", "."]: | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If you show stats for the sample code in issue 3618 (intentionally not linked to avoid irrelevant backref), it will show (see
With this change (strip leading
|
||
# This will always eventually find a valid expression because the | ||
# decorator or chained operator must be a valid Python function call, | ||
# so will eventually be syntactically valid and break out of the loop. | ||
# Thus, this loop can never terminate normally. | ||
for i in range(len(source) + 1): | ||
p = source[1:i] | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -234,7 +234,7 @@ def not_yet_in_unique_list(val): | |
while elements.more(): | ||
value = filtered.do_filtered_draw(data) | ||
if value is filter_not_satisfied: | ||
elements.reject("Aborted test because unable to satisfy {filtered!r}") | ||
elements.reject(f"Aborted test because unable to satisfy {filtered!r}") | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This one should be obvious. |
||
else: | ||
for key, seen in zip(self.keys, seen_sets): | ||
seen.add(key(value)) | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -153,7 +153,7 @@ def __repr__(self): | |
) | ||
|
||
def filter(self, condition): | ||
if condition in (str.lower, str.title, str.upper): | ||
if condition in self._nonempty_filters: | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. No idea, but it seemed like this was the intent? Otherwise, There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ah, this is tricky: here we're emitting a warning because it seems likely that you intended Adding a comment to explain that would be useful though! |
||
warnings.warn( | ||
f"You applied str.{condition.__name__} as a filter, but this allows " | ||
f"all nonempty strings! Did you mean str.is{condition.__name__}?", | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This makes verbose formatting similar to what is shown here: https://github.com/HypothesisWorks/hypothesis/blob/master/HypothesisWorks.github.io/_posts/2016-04-16-anatomy-of-a-test.md
I think that is much nicer, but I assume there's a reason it was
True
so feel free to say "no"...There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it's nice when the whole call fits on a single line, but much worse when all the arguments are on a single line after the test name, and that turns out to be common in practice. One-line-per-argument is a consistent way to get out of that, and also means that explain mode (#3555) looks similar to standard reports.