-
-
Notifications
You must be signed in to change notification settings - Fork 519
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix bug that prevented --format pretty and --format short from working (
- Loading branch information
Showing
7 changed files
with
79 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |