mirror of
https://github.com/jrnl-org/jrnl.git
synced 2025-05-10 16:48:31 +02:00
24 lines
1,006 B
Python
24 lines
1,006 B
Python
from behave import *
|
|
import shutil
|
|
import os
|
|
|
|
def before_scenario(context, scenario):
|
|
"""Before each scenario, backup all config and journal test data."""
|
|
for folder in ("configs", "journals"):
|
|
original = os.path.join("features", folder)
|
|
backup = os.path.join("features", folder+"_backup")
|
|
if not os.path.exists(backup):
|
|
os.mkdir(backup)
|
|
for filename in os.listdir(original):
|
|
shutil.copy2(os.path.join(original, filename), backup)
|
|
|
|
def after_scenario(context, scenario):
|
|
"""After each scenario, restore all test data and remove backups."""
|
|
for folder in ("configs", "journals"):
|
|
original = os.path.join("features", folder)
|
|
backup = os.path.join("features", folder+"_backup")
|
|
for filename in os.listdir(original):
|
|
os.remove(os.path.join(original, filename))
|
|
for filename in os.listdir(backup):
|
|
shutil.copy2(os.path.join(backup, filename), original)
|
|
shutil.rmtree(backup)
|