diff --git a/features/environment.py b/features/environment.py index e2fab73c..4843de45 100644 --- a/features/environment.py +++ b/features/environment.py @@ -2,6 +2,11 @@ import shutil import os import sys +def clean_all_working_dirs(): + for folder in ("configs", "journals", "cache"): + working_dir = os.path.join("features", folder) + if os.path.exists(working_dir): + shutil.rmtree(working_dir) def before_feature(context, feature): # add "skip" tag @@ -18,10 +23,7 @@ def before_feature(context, feature): def before_scenario(context, scenario): """Before each scenario, backup all config and journal test data.""" # Clean up in case something went wrong - for folder in ("configs", "journals", "cache"): - working_dir = os.path.join("features", folder) - if os.path.exists(working_dir): - shutil.rmtree(working_dir) + clean_all_working_dirs() for folder in ("configs", "journals"): original = os.path.join("features", "data", folder) @@ -48,7 +50,5 @@ def before_scenario(context, scenario): def after_scenario(context, scenario): """After each scenario, restore all test data and remove working_dirs.""" - for folder in ("configs", "journals", "cache"): - working_dir = os.path.join("features", folder) - if os.path.exists(working_dir): - shutil.rmtree(working_dir) + clean_all_working_dirs() +