mirror of
https://github.com/jrnl-org/jrnl.git
synced 2025-05-10 16:48:31 +02:00
Backup and restore config and journal files every time
This commit is contained in:
parent
47c90b6d40
commit
cd67ad73ea
1 changed files with 22 additions and 0 deletions
22
features/environment.py
Normal file
22
features/environment.py
Normal file
|
@ -0,0 +1,22 @@
|
|||
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(backup):
|
||||
shutil.copy2(os.path.join(backup, filename), original)
|
||||
shutil.rmtree(backup)
|
Loading…
Add table
Reference in a new issue