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

14 statements  

« prev     ^ index     » next       coverage.py v7.17.2, created at 2026-11-13 17:11 +0000

1from unittest.mock import patch 1nopqrstuvwxyz

2 

3import asyncer 1nopqrstuvwxyz

4import pytest 1nopqrstuvwxyz

5 

6from ...conftest import get_testing_print_function 1nopqrstuvwxyz

7 

8 

9def test_tutorial(): 1nopqrstuvwxyz

10 calls = [] 1abcdefghijklm

11 

12 new_print = get_testing_print_function(calls) 1abcdefghijklm

13 

14 with patch("builtins.print", new=new_print): 1abcdefghijklm

15 with pytest.raises((ExceptionGroup, asyncer.PendingValueException)) as e: 1abcdefghijklm

16 from docs_src.tutorial.soonify_return import tutorial002 as mod 1abcdefghijklm

17 

18 # Avoid autoflake removing this import 

19 assert mod # pragma: nocover 

20 if isinstance(e.value, ExceptionGroup): 1abcdefghijklm

21 assert isinstance(e.value.exceptions[0], asyncer.PendingValueException) 1abcdefghklm

22 else: 

23 assert isinstance(e.value, asyncer.PendingValueException) 1ij

24 assert calls == [] 1abcdefghijklm