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

1import errno 1habcdefg

2 

3import typer 1habcdefg

4import typer.completion 1habcdefg

5from typer.testing import CliRunner 1habcdefg

6 

7runner = CliRunner() 1habcdefg

8 

9 

10def test_eoferror(): 1habcdefg

11 # Mainly for coverage/completeness 

12 app = typer.Typer() 1habcdefg

13 

14 @app.command() 1habcdefg

15 def main(): 1abcdefg

16 raise EOFError() 1habcdefg

17 

18 result = runner.invoke(app) 1habcdefg

19 assert result.exit_code == 1 1habcdefg

20 

21 

22def test_oserror(): 1habcdefg

23 # Mainly for coverage/completeness 

24 app = typer.Typer() 1habcdefg

25 

26 @app.command() 1habcdefg

27 def main(): 1abcdefg

28 e = OSError() 1habcdefg

29 e.errno = errno.EPIPE 1habcdefg

30 raise e 1habcdefg

31 

32 result = runner.invoke(app) 1habcdefg

33 assert result.exit_code == 1 1habcdefg

34 

35 

36def test_oserror_no_epipe(): 1habcdefg

37 # Mainly for coverage/completeness 

38 app = typer.Typer() 1habcdefg

39 

40 @app.command() 1habcdefg

41 def main(): 1abcdefg

42 raise OSError() 1habcdefg

43 

44 result = runner.invoke(app) 1habcdefg

45 assert result.exit_code == 1 1habcdefg