Skip to content
This repository was archived by the owner on Aug 13, 2025. It is now read-only.

Commit ec1809e

Browse files
committed
Add --noclean option to pytest runner
Support the --noclean option to allow the user to keep the artifacts from any test run.
1 parent a12673f commit ec1809e

File tree

1 file changed

+14
-3
lines changed

1 file changed

+14
-3
lines changed

bin/tests/system/conftest.py

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,14 @@ def get_env(cmd):
108108

109109
# --------------------------- pytest hooks -------------------------------
110110

111+
def pytest_addoption(parser):
112+
parser.addoption(
113+
"--noclean",
114+
action="store_true",
115+
default=False,
116+
help="don't remove the temporary test directories with artifacts",
117+
)
118+
111119
def pytest_configure():
112120
# Ensure this hook only runs on the main pytest instance if xdist is
113121
# used to spawn other workers.
@@ -258,9 +266,12 @@ def system_test_dir(request, env, system_test_name, logger):
258266
os.chdir(old_cwd)
259267
logger.debug("changed workdir to: %s", old_cwd)
260268

261-
# cases when tempdir should be kept are handled in follow-up commits
262-
logger.debug("deleting temporary directory")
263-
shutil.rmtree(testdir)
269+
# Clean temporary dir unless it should be kept
270+
if request.config.getoption("--noclean"):
271+
logger.debug("--noclean requested, keeping temporary directory")
272+
else:
273+
logger.debug("deleting temporary directory")
274+
shutil.rmtree(testdir)
264275

265276
def _run_script( # pylint: disable=too-many-arguments
266277
env,

0 commit comments

Comments
 (0)