You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
test: subTest creates more problems than it solves with pytest >=9 #637
As of pytest 9 with pytest-xdist, the subTest method of unittest.TestCase now runs subtests across processes. This creates a requirement that subtest inputs must be process-serializable, which isn't satisified for various numba types.
A solution to this problem is to move towards pytest.mark.parametrize, which has no such requirement. I looked at our subTest usage, and AFAICT all of it parametrizes over static values, meaning it's a straightforward conversion.
The annoying thing is pytest will not parametrize unittest.TestCase test methods subclasses, only methods of classes that are not subclasses of TestCase.
I think this means that we need to move away from TestCase subclasses entirely, and unittest as well.
I think we can do this by moving the CUDATestCase setup and teardown to session/module/function fixtures as needed, and move the methods that it has to top level functions that can be imported from conftest.py.
I think we can preserve most of the test suite structure (e.g., not rewriting everything to function tests instead of classes) without that plugin.
That said, I don't think it ultimately matters that much since if we have to move away from subtest, then adding a new plugin that has the equivalent behavior to pytest.mark.parametrize seems like approximately the same amount of work as using the native decorator.
Activity
cpcloud commentedon Dec 5, 2025
For now, I'm going to set an upper bound on pytest to
<9so that we can continue to update other dependencies.gmarkall commentedon Dec 5, 2025
See also #619. I think there is an extension that allows parametrization of test classes: https://github.com/adamchainz/unittest-parametrize but I don't yet have a perspective on whether it's worth introducing instead of just converting the test suite to pytest.
cpcloud commentedon Dec 5, 2025
I think we can preserve most of the test suite structure (e.g., not rewriting everything to function tests instead of classes) without that plugin.
That said, I don't think it ultimately matters that much since if we have to move away from subtest, then adding a new plugin that has the equivalent behavior to
pytest.mark.parametrizeseems like approximately the same amount of work as using the native decorator.cpcloud commentedon Dec 5, 2025
In which case, not adding a dependency seems preferable.
ci: skip numba-cuda IPC tests and mlir test_device_record_copy
ci: clean up recurring nightly optional-deps failures (#2968)