From 981b5cac5d05145f8907b30a4776d2142613484b Mon Sep 17 00:00:00 2001 From: Arun Babu Neelicattu Date: Wed, 28 Apr 2021 01:56:03 +0200 Subject: [PATCH] tests: ensure ephemeral config usage Previously, pytest execution was influenced by poetry user configuration. This change ensures that a new config.toml is used each test case. --- tests/conftest.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/tests/conftest.py b/tests/conftest.py index 9481c31457b..d66ed9ba659 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -99,6 +99,15 @@ def config(config_source, auth_config_source, mocker): return c +@pytest.fixture(autouse=True) +def mock_user_config_dir(mocker): + config_dir = tempfile.mkdtemp(prefix="poetry_config_") + 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) def download_mock(mocker): # Patch download to not download anything but to just copy from fixtures