Skip to content

Commit e90e34d

Browse files
committed
Refactor test code
1 parent 520d018 commit e90e34d

File tree

3 files changed

+6
-16
lines changed

3 files changed

+6
-16
lines changed

hypothesis-python/tests/array_api/test_from_dtype.py

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -86,11 +86,7 @@ def smoke_test(_):
8686
),
8787
(xp.float32, {"allow_nan": False}, lambda x: not math.isnan(x)),
8888
(xp.float32, {"allow_infinity": False}, lambda x: not math.isinf(x)),
89-
(
90-
xp.float32,
91-
{"allow_nan": False, "allow_infinity": False},
92-
lambda x: not math.isnan(x) and not math.isinf(x),
93-
),
89+
(xp.float32, {"allow_nan": False, "allow_infinity": False}, math.isfinite),
9490
# Integer bounds, limited to the representable range
9591
(xp.int8, {"min_value": -1, "max_value": 1}, lambda x: -1 <= x <= 1),
9692
(xp.uint8, {"min_value": 1, "max_value": 2}, lambda x: 1 <= x <= 2),

hypothesis-python/tests/array_api/test_indices.py

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -25,20 +25,14 @@
2525
pytestmark = [pytest.mark.mockable_xp]
2626

2727

28-
@pytest.mark.parametrize(
29-
"condition",
30-
[
31-
lambda ix: Ellipsis in ix,
32-
lambda ix: Ellipsis not in ix,
33-
],
34-
)
35-
def test_indices_options(condition):
28+
def test_indices_options():
3629
indexers = (
3730
xps.array_shapes(min_dims=1, max_dims=32)
38-
.flatmap(lambda shape: xps.indices(shape))
31+
.flatmap(xps.indices)
3932
.map(lambda idx: idx if isinstance(idx, tuple) else (idx,))
4033
)
41-
find_any(indexers, condition)
34+
find_any(indexers, lambda ix: Ellipsis in ix)
35+
find_any(indexers, lambda ix: Ellipsis not in ix)
4236

4337

4438
def test_indices_can_generate_empty_tuple():

hypothesis-python/tests/array_api/test_pretty.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,6 @@ def test_namespaced_methods_meta(name):
7272
)
7373
def test_namespaced_strategies_repr(name, strat):
7474
"""Namespaced strategies have good repr."""
75-
assert repr(strat).startswith(name), f"{name} not in strat repr"
75+
assert repr(strat).startswith(name + "("), f"{name} not in strat repr {strat!r}"
7676
assert len(repr(strat)) < 100, "strat repr looks too long"
7777
assert xp.__name__ not in repr(strat), f"{xp.__name__} in strat repr"

0 commit comments

Comments
 (0)