cuda.core: Fix graphics tests - #2701
Open
juenglin wants to merge 7 commits into
Open
Conversation
Contributor
Stop treating graphics test-body failures as GL-unavailable skips, and bind a CUDA context in those tests so missing thread state cannot hide real errors.
juenglin
force-pushed
the
graphics-tests
branch
from
August 26, 2026 00:02
f348d94 to
d45b987
Compare
Contributor
Author
|
/ok to test baf3e23 |
|
juenglin
commented
Aug 26, 2026
|
|
||
| with patch.object(Buffer, "close", new=tracking_close): | ||
| resource.close(stream=close_stream) | ||
| @pytest.mark.xfail( |
Contributor
Author
There was a problem hiding this comment.
I couldn't get this test to work. Should I remove it?
============================================================= short test summary info =============================================================
FAILED cuda_core/tests/test_graphics.py::test_close_while_mapped_passes_stream_override - TypeError: cannot set 'close' attribute of immutable type 'cuda.core._memory._buffer.Buffer'
========================================================== 1 failed, 29 passed in 0.63s ===========================================================
juenglin
marked this pull request as ready for review
August 26, 2026 14:51
Contributor
Author
|
/ok to test 8fbb9cf |
Contributor
Author
|
pre-commit.ci run |
juenglin
force-pushed
the
graphics-tests
branch
from
August 27, 2026 15:47
c095715 to
5dc9814
Compare
Contributor
Author
|
/ok to test 5dc9814 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
The GL context helpers in
cuda_core/tests/test_graphics.pyandcuda_bindings/tests/test_graphics_apis.pywrappedyieldinexcept Exceptionand calledpytest.skip(), so CUDA errors, assertion failures, andTypeErrors raised in the test body were recorded as "could not create GL context" skips rather than failures. Thecuda_coregraphics tests also never requestedinit_cuda, so whetherfrom_gl_buffer/from_gl_imagesucceeded depended on leftover thread state from the previous test (pytest-randomlyseed).This PR:
_configure_pyglet_headless,_open_gl_window,_setup_gl_buffer,_setup_gl_texture) and a thin context manager that wraps only the setup call intry/exceptso test-body exceptions propagate as failures.init_cudato everycuda_coregraphics test that touches CUDA, and usesinit_cuda.create_stream()instead of a local_create_stream()helper.cuda_coretest classes to plain test functions (they carried no shared state or fixtures).StridedMemoryView.from_buffercall sites that passeddtype=np.float32(a scalar type class) instead ofnp.dtype(np.float32).test_close_while_mapped_passes_stream_overrideasxfail(strict=True)becauseBufferis an immutable Cython type and neitherpatch.objectnor__class__assignment can interceptBuffer.close.Checklist