Skip to content

Commit 8cf190d

Browse files
authored
Merge pull request #1157 from effigies/test/xdist
CI: Run tests with available parallelism
2 parents e5b67f1 + 17b0ef0 commit 8cf190d

File tree

3 files changed

+12
-6
lines changed

3 files changed

+12
-6
lines changed

nibabel/tests/test_api_validators.py

+10-5
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
""" Metaclass and class for validating instance APIs
22
"""
3-
3+
import os
4+
import pytest
45

56

67
class validator2test(type):
@@ -82,6 +83,10 @@ def validate_something(self, obj, params):
8283
assert obj.get_var() == params['var']
8384

8485

86+
@pytest.mark.xfail(
87+
os.getenv("PYTEST_XDIST_WORKER") is not None,
88+
reason="Execution in the same scope cannot be guaranteed"
89+
)
8590
class TestRunAllTests(ValidateAPI):
8691
""" Class to test that each validator test gets run
8792
@@ -98,7 +103,7 @@ def validate_first(self, obj, param):
98103
def validate_second(self, obj, param):
99104
self.run_tests.append('second')
100105

101-
102-
def teardown():
103-
# Check that both validate_xxx tests got run
104-
assert TestRunAllTests.run_tests == ['first', 'second']
106+
@classmethod
107+
def teardown_class(cls):
108+
# Check that both validate_xxx tests got run
109+
assert cls.run_tests == ['first', 'second']

setup.cfg

+1
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ test =
2424
pytest-cov
2525
pytest-doctestplus
2626
pytest-httpserver
27+
pytest-xdist
2728
zstd =
2829
pyzstd >= 0.14.3
2930
all =

tools/ci/check.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ elif [ "${CHECK_TYPE}" == "test" ]; then
2525
cd for_testing
2626
cp ../.coveragerc .
2727
pytest --doctest-modules --doctest-plus --cov nibabel --cov-report xml \
28-
--junitxml=test-results.xml -v --pyargs nibabel
28+
--junitxml=test-results.xml -v --pyargs nibabel -n auto
2929
else
3030
false
3131
fi

0 commit comments

Comments
 (0)