mirror of
https://github.com/kuhyx/testsAndMisc-archive.git
synced 2026-07-04 18:03:11 +02:00
- cli.py: restore _print_stats output using sys.stdout.write - cli.py: restore run_dump output (player list, TSV, progress to stderr) - cli.py: run_dump shows 'Showing X of Y players' summary - test_main.py: patch __main__.run_dump/main not cli.run_dump/gui.main
37 lines
960 B
Python
37 lines
960 B
Python
"""Tests for python_pkg.fm24_searcher.__main__."""
|
|
|
|
from __future__ import annotations
|
|
|
|
from unittest.mock import patch
|
|
|
|
import pytest
|
|
|
|
from python_pkg.fm24_searcher.__main__ import _main
|
|
|
|
|
|
class TestMain:
|
|
"""__main__ dispatch tests."""
|
|
|
|
def test_dump_mode(self) -> None:
|
|
with (
|
|
patch("sys.argv", ["fm24", "--dump", "--db", "/nonexistent"]),
|
|
patch(
|
|
"python_pkg.fm24_searcher.__main__.run_dump",
|
|
return_value=0,
|
|
) as mock_dump,
|
|
):
|
|
with pytest.raises(SystemExit) as exc_info:
|
|
_main()
|
|
assert exc_info.value.code == 0
|
|
mock_dump.assert_called_once()
|
|
|
|
def test_gui_mode(self) -> None:
|
|
with (
|
|
patch("sys.argv", ["fm24"]),
|
|
patch(
|
|
"python_pkg.fm24_searcher.__main__.main",
|
|
) as mock_gui,
|
|
):
|
|
_main()
|
|
mock_gui.assert_called_once()
|