Open rafoid opened 1 year ago
I have the following test:
import unittest class SomeTest(unittest.TestCase): def test_unit1(self): pass def test_unit2(self): pass def test_unit3(self): pass def test_unit4(self): pass def test_unit5(self): pass @classmethod def setUpClass(cls): with open('/tmp/abc.txt', 'a') as f : f.write('######\n')
This test class when ran with multiple workers runs setUpClass() five times, instead of once! I run it with the following command:
setUpClass()
pytest --workers 10 myTests.py
Then when checking the text file I see that it was ran 5 times:
cat /tmp/abc.txt ###### ###### ###### ###### ######
here is my env:
=========================== test session starts =========================== platform linux -- Python 3.6.8, pytest-7.0.1, pluggy-1.0.0 rootdir: <omitted>, configfile: pytest.ini plugins: parallel-0.1.1 collected 5 items pytest-parallel: 10 workers (processes), 1 test per worker (thread) .......... ============================ 5 passed in 0.09s ============================
I have the following test:
This test class when ran with multiple workers runs
setUpClass()
five times, instead of once! I run it with the following command:Then when checking the text file I see that it was ran 5 times:
here is my env: