Skip to content

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

@cpcloud

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions