Skip to content

test: subTest creates more problems than it solves with pytest >=9 #637

Description

@cpcloud

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.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions