Skip to content

Commit fc6cddf

Browse files
Simplify test_id generation to support tests running in parallel
Generating monotonically increasing number for test_id only works when tests are run sequentially. To support running in parallel, let's just use pytest's request.node.nodeid attribute to get the same behavior we had before using unittest.TestCase.id (e.g. cudapy/test_foo.py::TestFoo::test_foo1)
1 parent 57ee07d commit fc6cddf

2 files changed

Lines changed: 3 additions & 31 deletions

File tree

numba_cuda/numba/cuda/tests/support.py

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -223,17 +223,11 @@ def override_config(name, value):
223223
setattr(config, name, old_value)
224224

225225

226-
# This can certainly be divided into two pytest fixtures. However, doing so
227-
# means developers will have to import both 'test_id_generator' and the fixture
228-
# returning the itertools.count() generator. Importing could be avoided
229-
# altogether by adding the fixtures in conftest.py, but that potentially
230-
# pollutes the namespace
226+
# Returns string in following style:
227+
# 'cudapy/test_foo.py::TestFoo::test_foo1'
231228
@pytest.fixture(name="test_id")
232229
def test_id_generator(request):
233-
cls = request.cls
234-
if not hasattr(cls, "_test_id_counter"):
235-
cls._test_id_counter = itertools.count()
236-
yield next(cls._test_id_counter)
230+
yield request.node.nodeid
237231

238232

239233
def make_dummy_type(test_id):

numba_cuda/numba/cuda/tests/test_support.py

Lines changed: 0 additions & 22 deletions
This file was deleted.

0 commit comments

Comments
 (0)