Skip to content

Commit 00eb741

Browse files
DeborahOlaboyeSamWilsn
authored andcommitted
tests: write pytest logs under basetemp/tox workdir instead of repo root
1 parent c64d046 commit 00eb741

File tree

1 file changed

+12
-3
lines changed

1 file changed

+12
-3
lines changed

packages/tests/src/pytest_plugins/custom_logging/plugin_logging.py

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -317,9 +317,18 @@ def pytest_configure(config: pytest.Config) -> None:
317317

318318
worker_id = os.getenv("PYTEST_XDIST_WORKER", "main")
319319
log_filename = f"{log_stem}-{worker_id}.log"
320-
log_path = Path("logs")
321-
log_path.mkdir(exist_ok=True)
322-
log_file_path = log_path / log_filename
320+
basetemp_opt = getattr(config.option, "basetemp", None)
321+
tox_work_dir = os.environ.get("TOX_WORK_DIR")
322+
323+
if basetemp_opt:
324+
base_logs_dir = Path(str(basetemp_opt)) / "logs"
325+
elif tox_work_dir:
326+
base_logs_dir = Path(tox_work_dir) / "logs"
327+
else:
328+
base_logs_dir = Path("logs")
329+
330+
base_logs_dir.mkdir(parents=True, exist_ok=True)
331+
log_file_path = base_logs_dir / log_filename
323332

324333
# Store the log file path in the pytest config
325334
config.option.eest_log_file_path = log_file_path

0 commit comments

Comments
 (0)