Skip to content

test(conftest): skip GPU tests by marker, never by keyword - #50

Merged
mahdi-shafiei merged 2 commits into
mainfrom
fix/conftest-gpu-keyword
Nov 8, 2026
Merged

mahdi-shafiei merged 2 commits into
mainfrom
fix/conftest-gpu-keyword

Conversation

@mahdi-shafiei

Copy link
Copy Markdown
Collaborator

Summary

tests/conftest.py skipped any test whose keywords held "gpu" when no GPU was present. A test's keywords hold its markers, and also its parametrize id, its function and parent names and its function attributes, so an unmarked test parametrized with the value "gpu" was skipped on CPU. The root conftest already skips tests marked gpu or cuda through get_closest_marker.

 tests/conftest.py
-  pytest_configure: integration, e2e, benchmark, gpu, slow   # all registered in pyproject.toml
-  pytest_addoption: --integration (never read), --device (read only by the hook below)
-  pytest_collection_modifyitems: skip if "gpu" in item.keywords
 conftest.py
+  pytest_plugins = ("pytester",)
 tests/test_conftest_device_selection.py   (new)
 tests/test_conftest_teardown.py           ids no longer work around the skip

Two commits: the keyword skip and --device (test-first), then the redundant marker registrations and the unread --integration option.

Evidence

  • Before: the new test runs the suite's tests/conftest.py through pytester on an unmarked test parametrized with "gpu": {'skipped': 1} != {'skipped': 0}, 1 failed.
    After: 4 passed (the new test and the teardown test, now under its plain gpu/cuda ids).
  • Every test using the integration, e2e, benchmark, slow or gpu markers collects under --strict-markers --strict-config (19 tests); the 11 root-level test files pass (257); pre-commit passes on all files.
  • Nothing passed --device or read --integration (searched across the repository, CI and docs).

Merge Danger

Door: two-way

Blast Radius: test collection

CI selects tests by marker expression (ci.yml CI_PYTEST_MARKERS), which this does not touch.

tests/conftest.py skipped any test whose keywords held "gpu" when no GPU
was present. A test's keywords are its marker names, but also its
parametrize id, its function and parent names and its function
attributes, so an unmarked test parametrized with the value "gpu" was
skipped on CPU without carrying any marker. The root conftest already
skips tests marked gpu or cuda through get_closest_marker, so the hook
and the --device option it read are removed; nothing passed --device.

A pytester test runs the suite's tests/conftest.py on an unmarked test
whose parametrize id is gpu and asserts it runs; it was skipped before
the change. The teardown test drops the ids it used to avoid the same
skip.
…kes redundant

tests/conftest.py registered the integration, e2e, benchmark, gpu and
slow markers, all of which pyproject.toml already registers for
--strict-markers, and added an --integration option that nothing reads.
The suite's markers now have one registration, in pyproject.toml.
@mahdi-shafiei
mahdi-shafiei marked this pull request as ready for review November 8, 2026 22:40
@mahdi-shafiei
mahdi-shafiei merged commit 446308b into main Nov 8, 2026
13 checks passed
@mahdi-shafiei
mahdi-shafiei deleted the fix/conftest-gpu-keyword branch November 8, 2026 22:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant