Skip to content

Commit c66234c

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

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

tests/main_test.py

Lines changed: 21 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,
@@ -35,6 +36,26 @@ def static_path() -> Path:
3536
return Path(__file__).parent / "static"
3637

3738

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

0 commit comments

Comments
 (0)