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

17 statements  

« prev     ^ index     » next       coverage.py v7.13.4, created at 2026-05-05 09:41 +0000

1import sys 1ijklamn

2from unittest.mock import patch 1ijklamn

3 

4import asyncer 1ijklamn

5import pytest 1ijklamn

6 

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

8 from exceptiongroup import ExceptionGroup 1a

9 

10from ...conftest import get_testing_print_function 1ijklamn

11 

12 

13def test_tutorial(): 1ijklamn

14 calls = [] 1bcdefgh

15 

16 new_print = get_testing_print_function(calls) 1bcdefgh

17 

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

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

20 from docs_src.tutorial.soonify_return import tutorial002_py310 as mod 1bcdefgh

21 

22 # Avoid autoflake removing this import 

23 assert mod # pragma: nocover 

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

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

26 else: 

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

28 assert calls == [] 1bcdefgh