MCPcopy Index your code
hub / github.com/python-cmd2/cmd2 / test_not_in_main_thread

Function test_not_in_main_thread

tests/test_cmd2.py:66–79  ·  view source on GitHub ↗
(base_app, capsys)

Source from the content-addressed store, hash-verified

64
65
66def test_not_in_main_thread(base_app, capsys) -> None:
67 import threading
68
69 # Mock threading.main_thread() to return our fake thread
70 saved_main_thread = threading.main_thread
71 fake_main = threading.Thread()
72 threading.main_thread = mock.MagicMock(name="main_thread", return_value=fake_main)
73
74 with pytest.raises(RuntimeError) as excinfo:
75 base_app.cmdloop()
76
77 # Restore threading.main_thread()
78 threading.main_thread = saved_main_thread
79 assert "cmdloop must be run in the main thread" in str(excinfo.value)
80
81
82def test_empty_statement(base_app) -> None:

Callers

nothing calls this directly

Calls 1

cmdloopMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…