Coverage for tests/test_exit_errors.py: 100%
36 statements
« prev ^ index » next coverage.py v7.6.1, created at 2025-04-14 00:18 +0000
« prev ^ index » next coverage.py v7.6.1, created at 2025-04-14 00:18 +0000
1import errno 1iabcdefgh
3import typer 1iabcdefgh
4import typer.completion 1iabcdefgh
5from typer.testing import CliRunner 1iabcdefgh
7runner = CliRunner() 1iabcdefgh
10def test_eoferror(): 1iabcdefgh
11 # Mainly for coverage/completeness
12 app = typer.Typer() 1iabcdefgh
14 @app.command() 1iabcdefgh
15 def main(): 1abcdefgh
16 raise EOFError() 1iabcdefgh
18 result = runner.invoke(app) 1iabcdefgh
19 assert result.exit_code == 1 1iabcdefgh
22def test_keyboardinterrupt(): 1iabcdefgh
23 # Mainly for coverage/completeness
24 app = typer.Typer() 1iabcdefgh
26 @app.command() 1iabcdefgh
27 def main(): 1abcdefgh
28 raise KeyboardInterrupt() 1iabcdefgh
30 result = runner.invoke(app) 1iabcdefgh
31 assert result.exit_code == 130 1iabcdefgh
32 assert result.stdout == "" 1iabcdefgh
35def test_oserror(): 1iabcdefgh
36 # Mainly for coverage/completeness
37 app = typer.Typer() 1iabcdefgh
39 @app.command() 1iabcdefgh
40 def main(): 1abcdefgh
41 e = OSError() 1iabcdefgh
42 e.errno = errno.EPIPE 1iabcdefgh
43 raise e 1iabcdefgh
45 result = runner.invoke(app) 1iabcdefgh
46 assert result.exit_code == 1 1iabcdefgh
49def test_oserror_no_epipe(): 1iabcdefgh
50 # Mainly for coverage/completeness
51 app = typer.Typer() 1iabcdefgh
53 @app.command() 1iabcdefgh
54 def main(): 1abcdefgh
55 raise OSError() 1iabcdefgh
57 result = runner.invoke(app) 1iabcdefgh
58 assert result.exit_code == 1 1iabcdefgh