Skip to content

Commit

Permalink
tests: ensure mocked config reuses global temp dir
Browse files Browse the repository at this point in the history
This ensures clean up is consistent.
  • Loading branch information
abn committed Apr 26, 2022
1 parent 0e5f953 commit 42b8dde
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -190,13 +190,15 @@ def config(
return c


@pytest.fixture()
def config_dir(tmp_dir: str) -> str:
return tempfile.mkdtemp(prefix="poetry_config_", dir=tmp_dir)


@pytest.fixture(autouse=True)
def mock_user_config_dir(mocker: MockerFixture) -> Iterator[None]:
config_dir = tempfile.mkdtemp(prefix="poetry_config_")
def mock_user_config_dir(mocker: MockerFixture, config_dir: str) -> None:
mocker.patch("poetry.locations.CONFIG_DIR", new=config_dir)
mocker.patch("poetry.factory.CONFIG_DIR", new=config_dir)
yield
shutil.rmtree(config_dir, ignore_errors=True)


@pytest.fixture(autouse=True)
Expand Down

0 comments on commit 42b8dde

Please sign in to comment.