From 5e43db6cebf4fc5cf122684fba7241f8f1df0b4e Mon Sep 17 00:00:00 2001 From: Michael Droettboom Date: Mon, 30 Nov 2026 09:53:41 -0500 Subject: [PATCH] test(cuda.core): run the host_callback_cfunc node attribute tests and drop empty test_node_attrs and test_node_attrs_preserved_by_nodes skipped any node spec with no expected attributes, so [empty] and [host_callback_cfunc] never ran. - Give host_callback_cfunc a real expectation: a ctypes function pointer callback has no Python callable, so HostCallbackNode.callback is None. - Run the two tests over node_spec_with_attrs, which leaves out the empty node, and assert that every spec has expected attributes instead of skipping. Remove the "not currently run in any CI job" markers. Closes #3570. Co-Authored-By: Claude Opus 5.5 --- .../tests/graph/test_graph_definition.py | 38 +++++++++++-------- 1 file changed, 22 insertions(+), 16 deletions(-) diff --git a/cuda_core/tests/graph/test_graph_definition.py b/cuda_core/tests/graph/test_graph_definition.py index 3919d7b377ec..354276dfbc7e 100644 --- a/cuda_core/tests/graph/test_graph_definition.py +++ b/cuda_core/tests/graph/test_graph_definition.py @@ -391,7 +391,10 @@ def noop(data): pass node = g.callback(noop) - return node, {} + return node, { + # A ctypes function pointer callback has no Python callable. + "callback": lambda v: v is None, + } def _build_child_graph_node(g): @@ -550,9 +553,7 @@ def _build_switch_node(g): ] -@pytest.fixture(params=_NODE_SPECS) -def node_spec(request, init_cuda): - spec = request.param +def _build_node_spec(spec): if spec.needs_mempool: skip_if_mempool_unsupported() g = GraphDefinition() @@ -560,6 +561,17 @@ def node_spec(request, init_cuda): return spec, g, node, expected_attrs +@pytest.fixture(params=_NODE_SPECS) +def node_spec(request, init_cuda): + return _build_node_spec(request.param) + + +@pytest.fixture(params=[param for param in _NODE_SPECS if param.id != "empty"]) +def node_spec_with_attrs(request, init_cuda): + """Like ``node_spec``, without the empty node, which has no type-specific attributes.""" + return _build_node_spec(request.param) + + # ============================================================================= # Fixtures # ============================================================================= @@ -689,13 +701,10 @@ def test_node_type_preserved_by_pred_succ(node_spec): assert matched[0] is node -# For node_spec values empty and host_callback_cfunc: -# This test is not currently run in any CI job -def test_node_attrs(node_spec): +def test_node_attrs(node_spec_with_attrs): """Type-specific attributes have expected values after construction.""" - spec, g, node, expected_attrs = node_spec - if not expected_attrs: - pytest.skip("no type-specific attributes") + spec, g, node, expected_attrs = node_spec_with_attrs + assert expected_attrs, f"{spec.name}: no expected attributes" for attr, expected in expected_attrs.items(): actual = getattr(node, attr) if callable(expected): @@ -704,13 +713,10 @@ def test_node_attrs(node_spec): assert actual == expected, f"{spec.name}.{attr}: expected {expected}, got {actual}" -# For node_spec values empty and host_callback_cfunc: -# This test is not currently run in any CI job -def test_node_attrs_preserved_by_nodes(node_spec): +def test_node_attrs_preserved_by_nodes(node_spec_with_attrs): """Type-specific attributes survive round-trip through graph_definition.nodes().""" - spec, g, node, expected_attrs = node_spec - if not expected_attrs: - pytest.skip("no type-specific attributes") + spec, g, node, expected_attrs = node_spec_with_attrs + assert expected_attrs, f"{spec.name}: no expected attributes" if spec.roundtrip_class != spec.expected_class: pytest.skip("reconstructed type differs — attrs not preserved") retrieved = next(n for n in g.nodes() if n == node)