Skip to content

Commit

Permalink
make sure our error msg is styled and shown
Browse files Browse the repository at this point in the history
  • Loading branch information
Audiosutras committed Nov 13, 2023
1 parent 1fc5e38 commit 138742d
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion tests/test_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@
class TestPrintHelp:

def test_print_help(self, mocker):
spy = mocker.spy(click, "style")
msg = "Error msg"

class MockContext:

def get_help(self):
Expand All @@ -17,5 +20,10 @@ def exit(self):

mock_get_current_context = MockContext()
ctx = mocker.patch.object(click, "get_current_context", return_value=mock_get_current_context)
print_help("Yo")
print_help(msg)
# assert our message is styled with error styling (red).
# wrapped in click.echo so it will be shown
spy.assert_called_once_with(msg, fg="red")
# asserts that the context manager is fetched
# to show help text for a command
ctx.assert_called_once()

0 comments on commit 138742d

Please sign in to comment.