From 138742d3965cba73b400285810e822531f9a557e Mon Sep 17 00:00:00 2001 From: Christopher Dixon Date: Sun, 12 Nov 2023 21:08:00 -0500 Subject: [PATCH] make sure our error msg is styled and shown --- tests/test_utils.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/tests/test_utils.py b/tests/test_utils.py index 33b3da7..e2d1913 100644 --- a/tests/test_utils.py +++ b/tests/test_utils.py @@ -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): @@ -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()