testsAndMisc/python_pkg/brother_printer/tests/test_main_entry.py
Krzysztof kuhy Rudnicki 2545d72710 test: achieve 100% branch coverage across all python_pkg packages
- Add comprehensive tests for all packages (3572 tests, 100% branch coverage)
- Split oversized test files to stay under 500-line limit
- Add per-file ruff ignores for test-appropriate suppressions
- Fix _cache_decks.py to properly convert JSON lists to tuples
- Add session-scoped conftest fixture for logging handler cleanup (Python 3.14)
- Update ruff pre-commit hook to v0.15.2
- Add codespell ignore words for test data
- Add generated output files to .gitignore
2026-03-21 17:51:36 +01:00

30 lines
1007 B
Python

"""Tests for brother_printer.__main__ module."""
from __future__ import annotations
import importlib
import types
from unittest.mock import MagicMock, patch
class TestMain:
def test_main_called(self) -> None:
"""Test that __main__ calls main()."""
mock_main = MagicMock()
# Create a fake brother_printer.check_brother_printer module
fake_module = types.ModuleType("brother_printer.check_brother_printer")
vars(fake_module)["main"] = mock_main
with patch.dict(
"sys.modules",
{
"brother_printer": types.ModuleType("brother_printer"),
"brother_printer.check_brother_printer": fake_module,
},
):
# Remove cached __main__ module so it gets re-imported
import sys
sys.modules.pop("python_pkg.brother_printer.__main__", None)
importlib.import_module("python_pkg.brother_printer.__main__")
mock_main.assert_called_once()