()
| 922 | |
| 923 | |
| 924 | def test_cmdfinalization_hook_keyboard_interrupt() -> None: |
| 925 | app = PluggedApp() |
| 926 | app.register_cmdfinalization_hook(app.cmdfinalization_hook_keyboard_interrupt) |
| 927 | |
| 928 | # First make sure KeyboardInterrupt isn't raised unless told to |
| 929 | stop = app.onecmd_plus_hooks("say hello", raise_keyboard_interrupt=False) |
| 930 | assert not stop |
| 931 | assert app.called_cmdfinalization == 1 |
| 932 | |
| 933 | # Now enable raising the KeyboardInterrupt |
| 934 | app.reset_counters() |
| 935 | with pytest.raises(KeyboardInterrupt): |
| 936 | stop = app.onecmd_plus_hooks("say hello", raise_keyboard_interrupt=True) |
| 937 | assert not stop |
| 938 | assert app.called_cmdfinalization == 1 |
| 939 | |
| 940 | # Now make sure KeyboardInterrupt isn't raised if stop is already True |
| 941 | app.reset_counters() |
| 942 | stop = app.onecmd_plus_hooks("quit", raise_keyboard_interrupt=True) |
| 943 | assert stop |
| 944 | assert app.called_cmdfinalization == 1 |
| 945 | |
| 946 | |
| 947 | def test_cmdfinalization_hook_passthrough_exception() -> None: |
nothing calls this directly
no test coverage detected
searching dependent graphs…