diff --git a/features/steps/export_steps.py b/features/steps/export_steps.py index d560fbf7..93e03c1a 100644 --- a/features/steps/export_steps.py +++ b/features/steps/export_steps.py @@ -13,6 +13,7 @@ from behave import given from behave import then import colorama + def style_text(to_bold: bool, text_color: colorama.Fore, text_to_print: str): """Generate colorized and styled text for expected output. Its purpose is the same as Entry.colorize @@ -27,11 +28,10 @@ def style_text(to_bold: bool, text_color: colorama.Fore, text_to_print: str): """ if to_bold: text_style = Style.BRIGHT - else: + else: text_style = Style.NORMAL - text_color = getattr(colorama.Fore,text_color.upper(), None) - return text_style + text_color + text_to_print + Style.RESET_ALL - + text_color = getattr(colorama.Fore, text_color.upper(), None) + return text_style + text_color + text_to_print + Style.RESET_ALL @then("the output should be pretty printed") @@ -39,9 +39,17 @@ def check_export_pretty(context): out = context.stdout_capture.getvalue() lines = out.splitlines() - # As per the configuration, - expected_colorized_title = style_text(True, context.jrnl_config['colors']['date'].upper(), '2013-06-09 15:39') + ' ' + style_text(True, context.jrnl_config['colors']['title'].upper(), 'My first entry.') - assert lines[0] == expected_colorized_title + # As per the configuration, + expected_colorized_title = ( + style_text( + True, context.jrnl_config["colors"]["date"].upper(), "2013-06-09 15:39" + ) + + " " + + style_text( + True, context.jrnl_config["colors"]["title"].upper(), "My first entry." + ) + ) + assert lines[0] == expected_colorized_title @then("the output should be parsable as json")