Added repro_env_break debugging command. This spawn a terminal inside the temp home folder with the same environment as the python test
This commit is contained in:
@@ -11,14 +11,14 @@ log = logging.getLogger(__name__)
|
||||
|
||||
@pytest.fixture
|
||||
def temporary_home(monkeypatch: pytest.MonkeyPatch) -> Iterator[Path]:
|
||||
if os.getenv("TEST_KEEP_TEMPORARY_DIR") is not None:
|
||||
temp_dir = tempfile.mkdtemp(prefix="pytest-")
|
||||
path = Path(temp_dir)
|
||||
env_dir = os.getenv("TEST_TEMPORARY_DIR")
|
||||
if env_dir is not None:
|
||||
path = Path(env_dir).resolve()
|
||||
log.debug("Temp HOME directory: %s", str(path))
|
||||
monkeypatch.setenv("HOME", str(temp_dir))
|
||||
monkeypatch.setenv("HOME", str(path))
|
||||
yield path
|
||||
else:
|
||||
log.debug("TEST_KEEP_TEMPORARY_DIR not set, using TemporaryDirectory")
|
||||
log.debug("TEST_TEMPORARY_DIR not set, using TemporaryDirectory")
|
||||
with tempfile.TemporaryDirectory(prefix="pytest-") as dirpath:
|
||||
monkeypatch.setenv("HOME", str(dirpath))
|
||||
log.debug("Temp HOME directory: %s", str(dirpath))
|
||||
|
||||
Reference in New Issue
Block a user