mirror of
https://github.com/jrnl-org/jrnl.git
synced 2025-05-20 04:58:32 +02:00
implement behave test steps for format --pretty
This commit is contained in:
parent
1739cee1f0
commit
15efc56779
1 changed files with 15 additions and 7 deletions
|
@ -13,6 +13,7 @@ from behave import given
|
||||||
from behave import then
|
from behave import then
|
||||||
import colorama
|
import colorama
|
||||||
|
|
||||||
|
|
||||||
def style_text(to_bold: bool, text_color: colorama.Fore, text_to_print: str):
|
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
|
"""Generate colorized and styled text for expected output. Its purpose is the same as Entry.colorize
|
||||||
|
|
||||||
|
@ -29,18 +30,25 @@ def style_text(to_bold: bool, text_color: colorama.Fore, text_to_print: str):
|
||||||
text_style = Style.BRIGHT
|
text_style = Style.BRIGHT
|
||||||
else:
|
else:
|
||||||
text_style = Style.NORMAL
|
text_style = Style.NORMAL
|
||||||
text_color = getattr(colorama.Fore,text_color.upper(), None)
|
text_color = getattr(colorama.Fore, text_color.upper(), None)
|
||||||
return text_style + text_color + text_to_print + Style.RESET_ALL
|
return text_style + text_color + text_to_print + Style.RESET_ALL
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@then("the output should be pretty printed")
|
@then("the output should be pretty printed")
|
||||||
def check_export_pretty(context):
|
def check_export_pretty(context):
|
||||||
out = context.stdout_capture.getvalue()
|
out = context.stdout_capture.getvalue()
|
||||||
lines = out.splitlines()
|
lines = out.splitlines()
|
||||||
|
|
||||||
# As per the configuration,
|
# 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.')
|
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
|
assert lines[0] == expected_colorized_title
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue