diff --git a/pyproject.toml b/pyproject.toml index f36091db..73002860 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -66,6 +66,7 @@ test = [ "parameterized==0.9", "pytest>=7", "pytest-cov>=6.2.1", + "pytest-xdist>=3", "types-beautifulsoup4==4.12.0.20250516", "types-requests==2.33.0.20260518", "types-tqdm==4.68.0.20260608", @@ -85,7 +86,7 @@ envs.hatch-test.overrides.matrix.python.features = [ ] # pyproject.toml is the single source of truth for the environments CI tests: # the workflow reads this matrix via `hatch env show --json`. -envs.hatch-test.default-args = [ "tests" ] +envs.hatch-test.default-args = [ "-n", "auto", "tests" ] envs.hatch-test.dependency-groups = [ "test" ] [tool.ruff] diff --git a/tests/test_virus.py b/tests/test_virus.py index 12798ac1..673e0dbe 100644 --- a/tests/test_virus.py +++ b/tests/test_virus.py @@ -261,24 +261,11 @@ class TestVirus(unittest.TestCase, metaclass=from_json(virus_dict, virus)): See module docstring for detailed parameter coverage analysis. """ - @classmethod - def setUpClass(cls): - """Set up test fixtures that are shared across all tests.""" - cls.test_output_dir = "test_virus_output" - - @classmethod - def tearDownClass(cls): - """Clean up after all tests have run.""" - # Clean up test output directory if it exists - if os.path.exists(cls.test_output_dir): - shutil.rmtree(cls.test_output_dir) - def setUp(self): """Set up before each test method.""" - # Create a fresh test output directory - if os.path.exists(self.test_output_dir): - shutil.rmtree(self.test_output_dir) - os.makedirs(self.test_output_dir, exist_ok=True) + # Create a unique per-test output directory so tests can run in parallel + # (pytest-xdist) without racing on a shared, fixed directory. + self.test_output_dir = tempfile.mkdtemp(prefix="test_virus_") def tearDown(self): """Clean up after each test method."""