Skip to content

Commit

Permalink
run each test on its own temp dir
Browse files Browse the repository at this point in the history
  • Loading branch information
guiparpinelli committed Dec 13, 2023
1 parent 6a0a47c commit 21f8ce5
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions tests/conftest.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,21 @@
import sys
from pathlib import Path

import pytest


# each test runs on cwd to its temp dir
@pytest.fixture(autouse=True)
def go_to_tmpdir(request):
# Get the fixture dynamically by its name.
tmpdir = request.getfixturevalue("tmpdir")
# ensure local test created packages can be imported
sys.path.insert(0, str(tmpdir))
# Chdir only for the duration of the test.
with tmpdir.as_cwd():
yield


@pytest.fixture
def temp_dir(tmp_path: Path):
"""Create a temporary directory with some files inside it.
Expand Down

0 comments on commit 21f8ce5

Please sign in to comment.