File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -20,7 +20,7 @@ Internal
2020---------
2121* Add an ` AGENTS.md ` .
2222* Refactor ` find_matches() ` into smaller logical units.
23- * Increase test coverage.
23+ * Greatly increase test coverage.
2424* Remove some unused code.
2525* Better label Codex PR reviews.
2626* Improve gitignored files.
Original file line number Diff line number Diff line change 1+ from dataclasses import dataclass , field
2+ from typing import Any , cast
3+
4+ from mycli .packages .ptoolkit import utils as ptoolkit_utils
5+
6+
7+ @dataclass
8+ class DummyApp :
9+ print_calls : list [str ] = field (default_factory = list )
10+
11+ def print_text (self , text : str ) -> None :
12+ self .print_calls .append (text )
13+
14+
15+ def test_safe_invalidate_display_runs_empty_terminal_print (monkeypatch ) -> None :
16+ app = DummyApp ()
17+ callbacks : list [object ] = []
18+
19+ def fake_run_in_terminal (callback ) -> None :
20+ callbacks .append (callback )
21+ callback ()
22+
23+ monkeypatch .setattr (ptoolkit_utils , 'run_in_terminal' , fake_run_in_terminal )
24+
25+ ptoolkit_utils .safe_invalidate_display (cast (Any , app ))
26+
27+ assert len (callbacks ) == 1
28+ assert app .print_calls == ['' ]
29+
30+
31+ def test_safe_invalidate_display_swallows_runtime_error (monkeypatch ) -> None :
32+ app = DummyApp ()
33+
34+ def fail_run_in_terminal (_callback ) -> None :
35+ raise RuntimeError ('application is exiting' )
36+
37+ monkeypatch .setattr (ptoolkit_utils , 'run_in_terminal' , fail_run_in_terminal )
38+
39+ ptoolkit_utils .safe_invalidate_display (cast (Any , app ))
40+
41+ assert app .print_calls == []
You can’t perform that action at this time.
0 commit comments