Coverage for tests/test_tutorial/test_soonify_return/test_tutorial002.py: 100%

17 statements  

« prev     ^ index     » next       coverage.py v7.6.1, created at 2024-09-09 01:12 +0000

1import sys 1bcdij

2from unittest.mock import patch 1bcdij

3 

4import asyncer 1bcdij

5import pytest 1bcdij

6 

7if sys.version_info < (3, 11): 1bcdij

8 from exceptiongroup import ExceptionGroup 1bcd

9 

10from ...conftest import get_testing_print_function 1bcdij

11 

12 

13def test_tutorial(): 1bcdij

14 calls = [] 1eafgh

15 

16 new_print = get_testing_print_function(calls) 1eafgh

17 

18 with patch("builtins.print", new=new_print): 1eafgh

19 with pytest.raises((ExceptionGroup, asyncer.PendingValueException)) as e: 1eafgh

20 from docs_src.tutorial.soonify_return import tutorial002 as mod 1eafgh

21 

22 # Avoid autoflake removing this import 

23 assert mod # pragma: nocover 1a

24 if isinstance(e.value, ExceptionGroup): 1eafgh

25 assert isinstance(e.value.exceptions[0], asyncer.PendingValueException) 1ea

26 else: 

27 assert isinstance(e.value, asyncer.PendingValueException) 1fgh

28 assert calls == [] 1eafgh