update datetime tests

This commit is contained in:
Jonathan Wren 2020-09-19 17:16:26 -07:00
parent e5c1114ca2
commit 379a63c8f1
No known key found for this signature in database
GPG key ID: 43D5FF8722E7F68A
3 changed files with 91 additions and 24 deletions

View file

@ -5,6 +5,22 @@ from jrnl.os_compat import on_windows
CWD = os.getcwd()
# @see https://behave.readthedocs.io/en/latest/tutorial.html#debug-on-error-in-case-of-step-failures
BEHAVE_DEBUG_ON_ERROR = False
def setup_debug_on_error(userdata):
global BEHAVE_DEBUG_ON_ERROR
BEHAVE_DEBUG_ON_ERROR = userdata.getbool("BEHAVE_DEBUG_ON_ERROR")
def before_all(context):
setup_debug_on_error(context.config.userdata)
# def after_step(context, step):
# if BEHAVE_DEBUG_ON_ERROR and step.status == "failed":
# -- ENTER DEBUGGER: Zoom in on failure location.
# NOTE: Use IPython debugger, same for pdb (basic python debugger).
# import ipdb
# ipdb.post_mortem(step.exc_traceback)
def clean_all_working_dirs():
if os.path.exists("test.txt"):
@ -58,4 +74,8 @@ 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()
# only clean up if debugging is off and the scenario passed
if not BEHAVE_DEBUG_ON_ERROR and scenario.status != "failed":
clean_all_working_dirs()