mirror of
https://github.com/jrnl-org/jrnl.git
synced 2025-05-10 08:38:32 +02:00
* More refactoring of cli.py break up code from cli.py (now in jrnl.py) up into smaller functions get rid of export mode move --encrypt and --decrypt to commands.py clean up the help screen even more update flag name for import * reorganize code, move around lots of functions * clean up import statements * move run function out of cli and into jrnl * rename confusingly named function * move editor function into editor file * rename parse_args.py to args.py to make room for more args functions * Fix error in test suite for windows I accidentally flipped the conditional, so this fixes it. Co-authored-by: Micah Jerome Ellison <micah.jerome.ellison@gmail.com> * Update app description on help screen Co-authored-by: Micah Jerome Ellison <micah.jerome.ellison@gmail.com>
59 lines
1.8 KiB
Python
59 lines
1.8 KiB
Python
import os
|
|
import shutil
|
|
|
|
from jrnl.os_compat import on_windows
|
|
|
|
CWD = os.getcwd()
|
|
|
|
|
|
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
|
|
# https://stackoverflow.com/a/42721605/4276230
|
|
if "skip" in feature.tags:
|
|
feature.skip("Marked with @skip")
|
|
return
|
|
|
|
if "skip_win" in feature.tags and on_windows:
|
|
feature.skip("Skipping on Windows")
|
|
return
|
|
|
|
|
|
def before_scenario(context, scenario):
|
|
"""Before each scenario, backup all config and journal test data."""
|
|
# Clean up in case something went wrong
|
|
clean_all_working_dirs()
|
|
for folder in ("configs", "journals"):
|
|
original = os.path.join("features", "data", folder)
|
|
working_dir = os.path.join("features", folder)
|
|
if not os.path.exists(working_dir):
|
|
os.mkdir(working_dir)
|
|
for filename in os.listdir(original):
|
|
source = os.path.join(original, filename)
|
|
if os.path.isdir(source):
|
|
shutil.copytree(source, os.path.join(working_dir, filename))
|
|
else:
|
|
shutil.copy2(source, working_dir)
|
|
|
|
# add "skip" tag
|
|
# https://stackoverflow.com/a/42721605/4276230
|
|
if "skip" in scenario.effective_tags:
|
|
scenario.skip("Marked with @skip")
|
|
return
|
|
|
|
if "skip_win" in scenario.effective_tags and on_windows:
|
|
scenario.skip("Skipping on Windows")
|
|
return
|
|
|
|
|
|
def after_scenario(context, scenario):
|
|
"""After each scenario, restore all test data and remove working_dirs."""
|
|
if os.getcwd() != CWD:
|
|
os.chdir(CWD)
|
|
clean_all_working_dirs()
|