Skip to content

Commit a8cfc0e

Browse files
committed
feat(tests/main_test.py): add logging test suite
1 parent 9fe78e8 commit a8cfc0e

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

tests/main_test.py

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
InvalidDocTreeError,
1212
build_sphinx_tree,
1313
main,
14+
panic,
1415
publish,
1516
toctree_indexer,
1617
validate_documentation_tree,
@@ -34,6 +35,24 @@ def static_path() -> Path:
3435
"""Test static data folder."""
3536
return Path(__file__).parent / "static"
3637

38+
class TestLogging:
39+
"""Test suite for logging features."""
40+
41+
def test_panic_sys_exit(self, mocker: MockerFixture) -> None:
42+
"""Tests that panic properly exits program with error exit code."""
43+
exit_patch = mocker.patch("tovald.main.sys.exit")
44+
45+
panic("")
46+
exit_patch.assert_called_once_with(1)
47+
48+
def test_panic_print(self, mocker: MockerFixture) -> None:
49+
"""Tests that panic yields error message."""
50+
error_message = "test_panic_print"
51+
mocker.patch("tovald.main.sys.exit")
52+
print_patch = mocker.patch("tovald.main.print")
53+
54+
panic("test_panic_print")
55+
print_patch.assert_called_once_with(error_message)
3756

3857
class TestValidateDocumentationTree:
3958
"""Test suite for validate_documentation_tree function."""

0 commit comments

Comments
 (0)