Skip to content
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

Use convenience functions for choice sequence kwargs #4208

Merged
merged 1 commit into from
Dec 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading