Skip to content

Commit

Permalink
remove unecessary lambda x: True params
Browse files Browse the repository at this point in the history
  • Loading branch information
tybug committed Apr 26, 2024
1 parent 43977e4 commit cf0fed2
Show file tree
Hide file tree
Showing 7 changed files with 27 additions and 30 deletions.
10 changes: 4 additions & 6 deletions hypothesis-python/tests/cover/test_complex_numbers.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@


def test_minimal():
assert minimal(complex_numbers(), lambda x: True) == 0
assert minimal(complex_numbers()) == 0


def test_minimal_nonzero_real():
Expand Down Expand Up @@ -80,17 +80,15 @@ def test_min_magnitude_respected(data, mag):


def test_minimal_min_magnitude_zero():
assert minimal(complex_numbers(min_magnitude=0), lambda x: True) == 0
assert minimal(complex_numbers(min_magnitude=0)) == 0


def test_minimal_min_magnitude_positive():
assert minimal(complex_numbers(min_magnitude=0.5), lambda x: True) in (0.5, 1)
assert minimal(complex_numbers(min_magnitude=0.5)) in (0.5, 1)


def test_minimal_minmax_magnitude():
assert minimal(
complex_numbers(min_magnitude=0.5, max_magnitude=1.5), lambda x: True
) in (0.5, 1)
assert minimal(complex_numbers(min_magnitude=0.5, max_magnitude=1.5)) in (0.5, 1)


@given(st.data(), st.floats(0, 10e300, allow_infinity=False, allow_nan=False))
Expand Down
6 changes: 3 additions & 3 deletions hypothesis-python/tests/cover/test_composite.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@ def test_simplify_draws():


def test_can_pass_through_arguments():
assert minimal(badly_draw_lists(5), lambda x: True) == [0] * 5
assert minimal(badly_draw_lists(m=6), lambda x: True) == [0] * 6
assert minimal(badly_draw_lists(5)) == [0] * 5
assert minimal(badly_draw_lists(m=6)) == [0] * 6


@st.composite
Expand Down Expand Up @@ -95,7 +95,7 @@ def test_can_use_pure_args():
def stuff(*args):
return args[0](st.sampled_from(args[1:]))

assert minimal(stuff(1, 2, 3, 4, 5), lambda x: True) == 1
assert minimal(stuff(1, 2, 3, 4, 5)) == 1


def test_composite_of_lists():
Expand Down
2 changes: 1 addition & 1 deletion hypothesis-python/tests/cover/test_direct_strategies.py
Original file line number Diff line number Diff line change
Expand Up @@ -479,7 +479,7 @@ def test_iterables_are_exhaustible(it):


def test_minimal_iterable():
assert list(minimal(ds.iterables(ds.integers()), lambda x: True)) == []
assert list(minimal(ds.iterables(ds.integers()))) == []


@pytest.mark.parametrize("parameter_name", ["min_value", "max_value"])
Expand Down
4 changes: 2 additions & 2 deletions hypothesis-python/tests/cover/test_simple_characters.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ def test_exclude_characters_of_major_categories():


def test_find_one():
char = minimal(characters(min_codepoint=48, max_codepoint=48), lambda _: True)
char = minimal(characters(min_codepoint=48, max_codepoint=48))
assert char == "0"


Expand Down Expand Up @@ -138,7 +138,7 @@ def test_blacklisted_characters():
min_codepoint=ord("0"), max_codepoint=ord("9"), exclude_characters=bad_chars
)

assert "1" == minimal(st, lambda c: True)
assert "1" == minimal(st)

assert_no_examples(st, lambda c: c in bad_chars)

Expand Down
19 changes: 9 additions & 10 deletions hypothesis-python/tests/cover/test_simple_collections.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@
],
)
def test_find_empty_collection_gives_empty(col, strat):
assert minimal(strat, lambda x: True) == col
assert minimal(strat) == col


@pytest.mark.parametrize(
Expand All @@ -64,7 +64,7 @@ def test_find_non_empty_collection_gives_single_zero(coltype, strat):
("coltype", "strat"), [(list, lists), (set, sets), (frozenset, frozensets)]
)
def test_minimizes_to_empty(coltype, strat):
assert minimal(strat(integers()), lambda x: True) == coltype()
assert minimal(strat(integers())) == coltype()


def test_minimizes_list_of_lists():
Expand Down Expand Up @@ -96,12 +96,12 @@ def test_fixed_dictionaries_with_optional_and_empty_keys(d):

@pytest.mark.parametrize("n", range(10))
def test_lists_of_fixed_length(n):
assert minimal(lists(integers(), min_size=n, max_size=n), lambda x: True) == [0] * n
assert minimal(lists(integers(), min_size=n, max_size=n)) == [0] * n


@pytest.mark.parametrize("n", range(10))
def test_sets_of_fixed_length(n):
x = minimal(sets(integers(), min_size=n, max_size=n), lambda x: True)
x = minimal(sets(integers(), min_size=n, max_size=n))
assert len(x) == n

if not n:
Expand All @@ -113,9 +113,7 @@ def test_sets_of_fixed_length(n):
@pytest.mark.parametrize("n", range(10))
def test_dictionaries_of_fixed_length(n):
x = set(
minimal(
dictionaries(integers(), booleans(), min_size=n, max_size=n), lambda x: True
).keys()
minimal(dictionaries(integers(), booleans(), min_size=n, max_size=n)).keys()
)

if not n:
Expand Down Expand Up @@ -168,9 +166,10 @@ def test_small_sized_sets(x):


def test_minimize_dicts_with_incompatible_keys():
assert minimal(
fixed_dictionaries({1: booleans(), "hi": lists(booleans())}), lambda x: True
) == {1: False, "hi": []}
assert minimal(fixed_dictionaries({1: booleans(), "hi": lists(booleans())})) == {
1: False,
"hi": [],
}


@given(
Expand Down
2 changes: 1 addition & 1 deletion hypothesis-python/tests/nocover/test_find.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@


def test_can_find_an_int():
assert minimal(integers(), lambda x: True) == 0
assert minimal(integers()) == 0
assert minimal(integers(), lambda x: x >= 13) == 13


Expand Down
14 changes: 7 additions & 7 deletions hypothesis-python/tests/nocover/test_simple_numbers.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ def is_good(x):

assert minimal(integers(min_value=boundary - 10), is_good) == boundary

assert minimal(integers(min_value=boundary), lambda x: True) == boundary
assert minimal(integers(min_value=boundary)) == boundary


def test_minimizes_negative_integer_range_upwards():
Expand All @@ -67,11 +67,11 @@ def test_minimizes_negative_integer_range_upwards():

@boundaries
def test_minimizes_integer_range_to_boundary(boundary):
assert minimal(integers(boundary, boundary + 100), lambda x: True) == boundary
assert minimal(integers(boundary, boundary + 100)) == boundary


def test_single_integer_range_is_range():
assert minimal(integers(1, 1), lambda x: True) == 1
assert minimal(integers(1, 1)) == 1


def test_minimal_small_number_in_large_range():
Expand All @@ -97,11 +97,11 @@ def test_minimal_non_boundary_float():


def test_minimal_float_is_zero():
assert minimal(floats(), lambda x: True) == 0.0
assert minimal(floats()) == 0.0


def test_minimal_asymetric_bounded_float():
assert minimal(floats(min_value=1.1, max_value=1.6), lambda x: True) == 1.5
assert minimal(floats(min_value=1.1, max_value=1.6)) == 1.5


def test_negative_floats_simplify_to_zero():
Expand Down Expand Up @@ -176,8 +176,8 @@ def test_in_range(r):


def test_bounds_are_respected():
assert minimal(floats(min_value=1.0), lambda x: True) == 1.0
assert minimal(floats(max_value=-1.0), lambda x: True) == -1.0
assert minimal(floats(min_value=1.0)) == 1.0
assert minimal(floats(max_value=-1.0)) == -1.0


@pytest.mark.parametrize("k", range(10))
Expand Down

0 comments on commit cf0fed2

Please sign in to comment.