Repository navigation
tests/test_amd_swizzle: skip the numpy tests without numpy instead of failing - #6686
Conversation
… failing Without numpy the file sets A = None / HAVE_NUMPY = False, but the nine module-level pytest tests still called A.load / A.offsets, ran the numpy-importing CLI, or imported numpy, so 7 of them failed (seen on native Windows, Python 3.12 and 3.15). They are now skipped without numpy, as the __main__ block already skips them; the CLI guard tests fake numpy and still run. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Independent Windows CPU check of
The fallback cases remain exercised. Synthetic inputs only. AI-assisted. |
x2Tweek
left a comment
There was a problem hiding this comment.
Reviewed the diff for #6686 (tests/test_amd_swizzle.py: skip numpy tests when numpy is absent).
The change adds a needs_numpy skip decorator to the tests that require numpy, so they are skipped instead of failing when numpy is not installed. The pytest import is already present and conditionally handled at the top of the file (try: import pytest ... except ImportError: pytest = None), and HAVE_NUMPY is already computed from the amd_swizzle import. The decorator logic (if pytest is not None: ... else: def needs_numpy(fn): return fn) matches this pattern.
Tests that fake numpy internally (the CLI guard tests) still run, as intended.
This is a clean, minimal, CPU-only test fix. No game files, no GPU, no build needed.
AI-assisted.
🤖 Generated with Claude Code
|
Verified with and without numpy: without numpy the 10 numpy-dependent tests skip and the 4 fake-numpy CLI guards still pass (4 passed/10 skipped vs 7 failed on unmodified main); with numpy the result set is identical to main's, including 6 host-specific failures tied to the Windows-default AMD_SWIZZLE_HEADER path — the skips mask nothing. python -I is green. Flag: no CI checks reported. AI-assisted: yes. Tested on Linux (RTX 5080 host, CPU-only run). |
|
Tested e956e93 merged with main e0816d6 on Linux/Python 3.12.16: pass Test-only (
I did not run it on an interpreter that really lacks numpy (bare python3 here is 3.10 and has neither numpy nor pytest). |
shayderrr
left a comment
There was a problem hiding this comment.
Summary
tests/test_amd_swizzle.py defines a needs_numpy marker — pytest.mark.skipif(not HAVE_NUMPY, reason="numpy is not installed") under pytest, a no-op decorator otherwise — and applies it to the module-level tests that import or exercise numpy (test_symbols_and_xor, test_rejects_code, the detile/preview tests, and the parametrized test_cli_previews_uncompressed_r8_and_rg8). CLI guard tests that fake numpy are deliberately left unmarked and continue to run without it.
Why merge
The __main__ block already skipped these tests without numpy; aligning pytest with that behavior removes nine spurious failures in a bare test environment while keeping dependency-free coverage.
Verdict: Approve
Summary
Why mergeThe Verdict: Approve |
Claimed in the coordination issue as: new TEST item, #6603 (comment)
Depends on: none. Touches the same file as #4951 (the
__main__block, a different part), whichever lands first.What and why
tests/test_amd_swizzle.pyhandles a missing numpy at import (A = None,HAVE_NUMPY = False, lines 25-31), and its__main__block skips the numpy tests. Under pytest, though, the nine module-level tests still ran. They calledA.load/A.offsetsonNone, ran the numpy-importing CLI in a subprocess, or imported numpy directly. Without numpy, 7 of them fail withAttributeError: 'NoneType'/ModuleNotFoundError: numpy. CI installs numpy, so only a contributor's machine sees this. I found it on native Windows with Python 3.12 and 3.15.The change adds a
needs_numpymarker,pytest.mark.skipif(not HAVE_NUMPY), which is a no-op when pytest isn't importable. The module-level tests carry it. TheAmdSwizzleCliGuardTestsunittest class fakes numpy and keeps running. With numpy, nothing changes.Tested
Windows 11, no numpy:
python -m pytest tests/test_amd_swizzle.py: was 7 failed. Now 4 passed, 10 skipped ("numpy is not installed"), on Python 3.12 and 3.15.python -I tests/test_amd_swizzle.py: OK (4 tests).No GPU involved.
AI-assisted: yes (Claude Code)
Checklist
docs/design.md, with how it was confirmed. (n/a: no translator change)