mirror of
https://github.com/jrnl-org/jrnl.git
synced 2025-06-28 13:36:14 +02:00
remove py2 remnants and use mocks in tests
fstring wip Run pyupgrade fix broken pyupgrade fstring run pyupgrade on plugin dir fixup! remove py2 remnants and use mocks in tests small print bugfix The file=sys.stderr was part of the format(), so an error got printed to stdout Drop use of codecs package Use builtins.open() instead fixup! remove py2 remnants and use mocks in tests
This commit is contained in:
parent
b7e2e91af3
commit
9d8d6a83ae
28 changed files with 211 additions and 321 deletions
|
@ -1,25 +1,15 @@
|
|||
from behave import *
|
||||
import shutil
|
||||
import os
|
||||
import jrnl
|
||||
try:
|
||||
from io import StringIO
|
||||
except ImportError:
|
||||
from cStringIO import StringIO
|
||||
|
||||
|
||||
def before_scenario(context, scenario):
|
||||
"""Before each scenario, backup all config and journal test data."""
|
||||
context.messages = StringIO()
|
||||
jrnl.util.STDERR = context.messages
|
||||
jrnl.util.TEST = True
|
||||
|
||||
# Clean up in case something went wrong
|
||||
for folder in ("configs", "journals"):
|
||||
working_dir = os.path.join("features", folder)
|
||||
if os.path.exists(working_dir):
|
||||
shutil.rmtree(working_dir)
|
||||
|
||||
|
||||
for folder in ("configs", "journals"):
|
||||
original = os.path.join("features", "data", folder)
|
||||
working_dir = os.path.join("features", folder)
|
||||
|
@ -32,10 +22,9 @@ def before_scenario(context, scenario):
|
|||
else:
|
||||
shutil.copy2(source, working_dir)
|
||||
|
||||
|
||||
def after_scenario(context, scenario):
|
||||
"""After each scenario, restore all test data and remove working_dirs."""
|
||||
context.messages.close()
|
||||
context.messages = None
|
||||
for folder in ("configs", "journals"):
|
||||
working_dir = os.path.join("features", folder)
|
||||
if os.path.exists(working_dir):
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue