mirror of
https://github.com/jrnl-org/jrnl.git
synced 2025-06-27 21:16:14 +02:00
Fix bug that prevented --format pretty and --format short from working (#1177)
This commit is contained in:
parent
b9a6d029e2
commit
a3f4f6b944
7 changed files with 79 additions and 2 deletions
17
tests/test_color.py
Normal file
17
tests/test_color.py
Normal file
|
@ -0,0 +1,17 @@
|
|||
import pytest
|
||||
|
||||
from jrnl.color import colorize
|
||||
from colorama import Fore, Style
|
||||
|
||||
|
||||
@pytest.fixture()
|
||||
def data_fixture():
|
||||
string = "Zwei peanuts walked into a bar"
|
||||
yield string
|
||||
|
||||
|
||||
def test_colorize(data_fixture):
|
||||
string = data_fixture
|
||||
colorized_string = colorize(string, "BLUE", True)
|
||||
|
||||
assert colorized_string == Style.BRIGHT + Fore.BLUE + string + Style.RESET_ALL
|
23
tests/test_display.py
Normal file
23
tests/test_display.py
Normal file
|
@ -0,0 +1,23 @@
|
|||
import argparse
|
||||
import jrnl
|
||||
import pytest
|
||||
from unittest import mock
|
||||
from jrnl.jrnl import _display_search_results
|
||||
|
||||
|
||||
# fmt: off
|
||||
# see: https://github.com/psf/black/issues/664
|
||||
@pytest.mark.parametrize("export_format", [ "pretty", "short","markdown"])
|
||||
#fmt: on
|
||||
@mock.patch.object(argparse, "Namespace", return_value={"export": "markdown", "filename": "irrele.vant"})
|
||||
def test_export_format(mock_args, export_format):
|
||||
|
||||
test_journal = jrnl.Journal.Journal
|
||||
mock_args.export = export_format
|
||||
#fmt: off
|
||||
# see: https://github.com/psf/black/issues/664
|
||||
with mock.patch("builtins.print") as mock_spy_print, \
|
||||
mock.patch('jrnl.Journal.Journal.pprint') as mock_pprint:
|
||||
_display_search_results(mock_args, test_journal)
|
||||
mock_spy_print.assert_called_once_with(mock_pprint())
|
||||
#fmt: on
|
Loading…
Add table
Add a link
Reference in a new issue