Skip to content

Commit 93eb6d5

Browse files
Andy-Jostclaude
andauthored
test(cuda.core): fold the pairwise cross-type object-protocol tests into one equality test (#3044)
No linked issue; test-suite maintenance. Refs #2745. Co-authored-by: Claude Fable 5.1 <[email protected]>
1 parent 05a309f commit 93eb6d5

1 file changed

Lines changed: 30 additions & 10 deletions

File tree

‎cuda_core/tests/test_object_protocols.py‎

Lines changed: 30 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -545,6 +545,27 @@ def sample_object_b(request):
545545
return request.getfixturevalue(request.param)
546546

547547

548+
@pytest.fixture
549+
def eq_samples(request, init_cuda):
550+
"""Every EQ_TYPES sample keyed by fixture name, resolved here at setup on the main thread.
551+
552+
A sample whose fixture skips is dropped and recorded in the test's JUnit properties, so the
553+
remaining types are still compared on devices that lack a feature.
554+
"""
555+
samples = {}
556+
skipped = []
557+
for name in EQ_TYPES:
558+
try:
559+
samples[name] = request.getfixturevalue(name)
560+
except pytest.skip.Exception as exc:
561+
skipped.append(f"{name}: {exc}")
562+
if skipped:
563+
request.node.user_properties.append(("skipped_samples", "; ".join(skipped)))
564+
if len(samples) < 2:
565+
pytest.skip("fewer than two EQ_TYPES samples resolved; " + "; ".join(skipped))
566+
return samples
567+
568+
548569
# =============================================================================
549570
# Type groupings
550571
# =============================================================================
@@ -813,12 +834,6 @@ def test_hash_distinct_same_type(sample_object_a, sample_object_b):
813834
assert hash(sample_object_a) != hash(sample_object_b) # extremely unlikely
814835

815836

816-
@pytest.mark.parametrize("sample_object_a,sample_object_b", itertools.combinations(HASH_TYPES, 2), indirect=True)
817-
def test_hash_distinct_cross_type(sample_object_a, sample_object_b):
818-
"""Distinct objects of different types have different hashes."""
819-
assert hash(sample_object_a) != hash(sample_object_b) # extremely unlikely
820-
821-
822837
# =============================================================================
823838
# Equality tests
824839
# =============================================================================
@@ -834,10 +849,15 @@ def test_equality_basic(sample_object):
834849
assert sample_object != sample_object.handle
835850

836851

837-
@pytest.mark.parametrize("sample_object_a,sample_object_b", itertools.combinations(EQ_TYPES, 2), indirect=True)
838-
def test_no_cross_type_equality(sample_object_a, sample_object_b):
839-
"""No two distinct objects of different types should compare equal."""
840-
assert sample_object_a != sample_object_b
852+
@pytest.mark.agent_authored(model="claude-fable-5-1")
853+
def test_no_cross_type_equality(eq_samples):
854+
"""No two objects of different types compare equal."""
855+
equal_pairs = [
856+
(name_a, name_b)
857+
for (name_a, obj_a), (name_b, obj_b) in itertools.combinations(eq_samples.items(), 2)
858+
if obj_a == obj_b or not (obj_a != obj_b) # noqa: SIM202 - checks __eq__ and __ne__ separately
859+
]
860+
assert equal_pairs == []
841861

842862

843863
@pytest.mark.parametrize("sample_object_a,sample_object_b", SAME_TYPE_PAIRS, indirect=True)

0 commit comments

Comments
 (0)