From f2897ea20b354aa58ddaca55f4fb02da00078020 Mon Sep 17 00:00:00 2001 From: Zac Hatfield-Dodds Date: Sun, 8 Jan 2023 19:50:16 +1100 Subject: [PATCH] Text fixes --- .../tests/cover/test_custom_reprs.py | 6 +++++- .../tests/quality/test_discovery_ability.py | 18 ++++++++++-------- 2 files changed, 15 insertions(+), 9 deletions(-) diff --git a/hypothesis-python/tests/cover/test_custom_reprs.py b/hypothesis-python/tests/cover/test_custom_reprs.py index d8bf4ef496..24f4542903 100644 --- a/hypothesis-python/tests/cover/test_custom_reprs.py +++ b/hypothesis-python/tests/cover/test_custom_reprs.py @@ -12,7 +12,7 @@ import pytest -from hypothesis import given, strategies as st +from hypothesis import given, settings, strategies as st def test_includes_non_default_args_in_repr(): @@ -79,6 +79,7 @@ class Bar(Foo): def test_reprs_as_created(): @given(st.builds(Foo), st.from_type(Bar), st.none().map(Foo)) + @settings(print_blob=False) def inner(foo, bar, baz): assert baz.x is None assert foo.x <= 0 or bar.x >= 0 @@ -97,6 +98,7 @@ def inner(foo, bar, baz): def test_reprs_as_created_interactive(): @given(st.data()) + @settings(print_blob=False) def inner(data): bar = data.draw(st.builds(Bar, st.just(10))) assert not bar.x @@ -123,6 +125,7 @@ def test_as_created_reprs_fallback_for_distinct_calls_same_obj(): # If we have *different* calls which return the *same* object, we skip our # nice repr because it's unclear which one we should use. @given(st.builds(some_foo), st.builds(some_foo, st.none())) + @settings(print_blob=False) def inner(a, b): assert a is not b @@ -143,6 +146,7 @@ def test_reprs_as_created_consistent_calls_despite_indentation(): # If we have multiple calls which return the same object, we can print their # nice repr even if varying indentation means that they'll come out different! @given(strat, st.builds(Bar, strat)) + @settings(print_blob=False) def inner(a, b): assert a == b diff --git a/hypothesis-python/tests/quality/test_discovery_ability.py b/hypothesis-python/tests/quality/test_discovery_ability.py index 0e6d9c0378..1d5c7ae4f1 100644 --- a/hypothesis-python/tests/quality/test_discovery_ability.py +++ b/hypothesis-python/tests/quality/test_discovery_ability.py @@ -23,6 +23,7 @@ import re from hypothesis import HealthCheck, settings as Settings +from hypothesis.control import BuildContext from hypothesis.errors import UnsatisfiedAssumption from hypothesis.internal import reflection from hypothesis.internal.conjecture.engine import ConjectureRunner @@ -73,14 +74,15 @@ def _condition(x): ) def test_function(data): - try: - value = data.draw(specifier) - except UnsatisfiedAssumption: - data.mark_invalid() - if not _condition(value): - data.mark_invalid() - if predicate(value): - data.mark_interesting() + with BuildContext(data): + try: + value = data.draw(specifier) + except UnsatisfiedAssumption: + data.mark_invalid() + if not _condition(value): + data.mark_invalid() + if predicate(value): + data.mark_interesting() successes = 0 actual_runs = 0