Skip to content
Snippets Groups Projects
Commit 673f9c72 authored by lukas leufen's avatar lukas leufen
Browse files

refac conftest

parent ef577861
No related branches found
No related tags found
3 merge requests!125Release v0.10.0,!124Update Master to new version v0.10.0,!103Lukas tech apply changes from 119
Pipeline #39349 passed
......@@ -16,19 +16,24 @@ def pytest_runtest_teardown(item, nextitem):
path = os.path.dirname(__file__)
for stage in filter(None, rel_path.replace("..", ".").split("/")):
path = os.path.abspath(os.path.join(path, stage))
execute_removing(path)
execute_removing(os.path.dirname(__file__))
else:
pass # nothing to do if next test is from same test class
def execute_removing(path):
list_dir = os.listdir(path)
if "data" in list_dir and path != os.path.dirname(__file__): # do not delete data folder in src
shutil.rmtree(os.path.join(path, "data"), ignore_errors=True)
if "TestExperiment" in list_dir:
shutil.rmtree(os.path.join(path, "TestExperiment"), ignore_errors=True)
# remove TestExperiment folders
remove_files_from_regex(list_dir, path, re.compile(r"TestExperiment_.*"))
# remove all tracking json
remove_files_from_regex(list_dir, path, re.compile(r"tracking_\d*\.json"))
# remove all tracking pdf
remove_files_from_regex(list_dir, path, re.compile(r"tracking\.pdf"))
remove_files_from_regex(list_dir, path, re.compile(r"tracking_\d*\.pdf"))
# remove all tracking json
remove_files_from_regex(list_dir, path, re.compile(r"logging_\d*\.log"))
else:
pass # nothing to do if next test is from same test class
def remove_files_from_regex(list_dir, path, regex):
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment