Coverage for tests/test_exit_errors.py: 100%
28 statements
« prev ^ index » next coverage.py v7.6.1, created at 2024-09-09 18:26 +0000
« prev ^ index » next coverage.py v7.6.1, created at 2024-09-09 18:26 +0000
1import errno 1habcdefg
3import typer 1habcdefg
4import typer.completion 1habcdefg
5from typer.testing import CliRunner 1habcdefg
7runner = CliRunner() 1habcdefg
10def test_eoferror(): 1habcdefg
11 # Mainly for coverage/completeness
12 app = typer.Typer() 1habcdefg
14 @app.command() 1habcdefg
15 def main(): 1abcdefg
16 raise EOFError() 1habcdefg
18 result = runner.invoke(app) 1habcdefg
19 assert result.exit_code == 1 1habcdefg
22def test_oserror(): 1habcdefg
23 # Mainly for coverage/completeness
24 app = typer.Typer() 1habcdefg
26 @app.command() 1habcdefg
27 def main(): 1abcdefg
28 e = OSError() 1habcdefg
29 e.errno = errno.EPIPE 1habcdefg
30 raise e 1habcdefg
32 result = runner.invoke(app) 1habcdefg
33 assert result.exit_code == 1 1habcdefg
36def test_oserror_no_epipe(): 1habcdefg
37 # Mainly for coverage/completeness
38 app = typer.Typer() 1habcdefg
40 @app.command() 1habcdefg
41 def main(): 1abcdefg
42 raise OSError() 1habcdefg
44 result = runner.invoke(app) 1habcdefg
45 assert result.exit_code == 1 1habcdefg