Как я могу запустить 4 теста одновременно при параллельном тестировании на 4 разных процессах с помощью тестов Django?
Я пытаюсь проверить, правильно ли изолированы мои тесты, и ломаю голову, как проще всего это сделать.
В основном мне нужна реализация барьера.
- 4 процесса останавливается, подхватывает каждый из тестов, ждет, пока все они будут готовы .
- я должен вызывать тесты с помощью
python manage.py test --parallel
- каждый тест - это класс
что у меня есть:
class TestCacheIndependentInParallel:
def test_cache_not_varying(self):
cache.set('key', self.cache_value)
for _ in range(100):
self.assertEqual(cache.get('key'), self.cache_value)
time.sleep(random.uniform(0.001, 0.005))
cache.set('key', self.cache_value)
class TestCachesIndependentInParallel_1(TestCase, TestCacheIndependentInParallel):
cache_value = 1
class TestCachesIndependentInParallel_2(TestCase, TestCacheIndependentInParallel):
cache_value = 2
class TestCachesIndependentInParallel_3(TestCase, TestCacheIndependentInParallel):
cache_value = 3
class TestCachesIndependentInParallel_4(TestCase, TestCacheIndependentInParallel):
cache_value = 4
Я должен быть уверен, что тесты 1-4 действительно выполняются параллельно друг другу.