Skip to content

Commit

Permalink
Merge pull request #4208 from tybug/test-cleanup
Browse files Browse the repository at this point in the history
Use convenience functions for choice sequence kwargs
  • Loading branch information
tybug authored Dec 22, 2024
2 parents 06c0e6a + e3f4e8d commit e19d812
Show file tree
Hide file tree
Showing 5 changed files with 97 additions and 459 deletions.
12 changes: 6 additions & 6 deletions hypothesis-python/tests/conjecture/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -430,9 +430,9 @@ def ir(*values: list[IRType]) -> list[IRNode]:
return tuple(nodes)


def make_float_kw(
min_value,
max_value,
def float_kw(
min_value=-math.inf,
max_value=math.inf,
*,
allow_nan=True,
smallest_nonzero_magnitude=SMALLEST_SUBNORMAL,
Expand All @@ -445,7 +445,7 @@ def make_float_kw(
}


def make_integer_kw(min_value, max_value, *, weights=None, shrink_towards=0):
def integer_kw(min_value=None, max_value=None, *, weights=None, shrink_towards=0):
return {
"min_value": min_value,
"max_value": max_value,
Expand All @@ -454,9 +454,9 @@ def make_integer_kw(min_value, max_value, *, weights=None, shrink_towards=0):
}


def make_string_kw(intervals, *, min_size=0, max_size=COLLECTION_DEFAULT_MAX_SIZE):
def string_kw(intervals, *, min_size=0, max_size=COLLECTION_DEFAULT_MAX_SIZE):
return {"intervals": intervals, "min_size": min_size, "max_size": max_size}


# we could in theory define make_bytes_kw and make_boolean_kw, but without any
# we could in theory define bytes_kw and boolean_kw, but without any
# default kw values they aren't really a time save.
13 changes: 2 additions & 11 deletions hypothesis-python/tests/conjecture/test_engine.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@
SOME_LABEL,
TEST_SETTINGS,
buffer_size_limit,
integer_kw,
ir,
ir_nodes,
run_to_nodes,
Expand Down Expand Up @@ -1627,17 +1628,7 @@ def test_simulate_to_evicted_data(monkeypatch):
# cache evictions (but also potentially other trickery).
monkeypatch.setattr(engine_module, "CACHE_SIZE", 1)

node_0 = IRNode(
ir_type="integer",
value=0,
kwargs={
"min_value": None,
"max_value": None,
"weights": None,
"shrink_towards": 0,
},
was_forced=False,
)
node_0 = IRNode(ir_type="integer", value=0, kwargs=integer_kw(), was_forced=False)
node_1 = node_0.copy(with_value=1)

def test(data):
Expand Down
Loading

0 comments on commit e19d812

Please sign in to comment.