This repository was archived by the owner on May 29, 2024. It is now read-only.

Description
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:
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 ============================