Skip to content

Commit ce51ee9

Browse files
effigiesDimitriPapadopoulos
authored andcommitted
TEST: Tolerate distributing tests across workers
1 parent e5b67f1 commit ce51ee9

File tree

1 file changed

+10
-5
lines changed

1 file changed

+10
-5
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']

0 commit comments

Comments
 (0)