Coverage for tests/test_tutorial/test_select/test_tutorial001_py310_tutorial002_py310.py: 100%
28 statements
« prev ^ index » next coverage.py v7.11.0, created at 2025-10-27 00:03 +0000
« prev ^ index » next coverage.py v7.11.0, created at 2025-10-27 00:03 +0000
1from typing import Any, Dict, List, Union 1qrstuvwxyz
2from unittest.mock import patch 1qrstuvwxyz
4from sqlmodel import create_engine 1qrstuvwxyz
6from ...conftest import get_testing_print_function, needs_py310 1qrstuvwxyz
9def check_calls(calls: List[List[Union[str, Dict[str, Any]]]]): 1qrstuvwxyz
10 assert calls[0][0] == { 1abcdefghijklmnop
11 "name": "Deadpond",
12 "secret_name": "Dive Wilson",
13 "age": None,
14 "id": 1,
15 }
16 assert calls[1][0] == { 1abcdefghijklmnop
17 "name": "Spider-Boy",
18 "secret_name": "Pedro Parqueador",
19 "age": None,
20 "id": 2,
21 }
22 assert calls[2][0] == { 1abcdefghijklmnop
23 "name": "Rusty-Man",
24 "secret_name": "Tommy Sharp",
25 "age": 48,
26 "id": 3,
27 }
30@needs_py310 1qrstuvwxyz
31def test_tutorial_001(clear_sqlmodel): 1qrstuvwxyz
32 from docs_src.tutorial.select import tutorial001_py310 as mod 1acegikmo
34 mod.sqlite_url = "sqlite://" 1acegikmo
35 mod.engine = create_engine(mod.sqlite_url) 1acegikmo
36 calls = [] 1acegikmo
38 new_print = get_testing_print_function(calls) 1acegikmo
40 with patch("builtins.print", new=new_print): 1acegikmo
41 mod.main() 1acegikmo
42 check_calls(calls) 1acegikmo
45@needs_py310 1qrstuvwxyz
46def test_tutorial_002(clear_sqlmodel): 1qrstuvwxyz
47 from docs_src.tutorial.select import tutorial002_py310 as mod 1bdfhjlnp
49 mod.sqlite_url = "sqlite://" 1bdfhjlnp
50 mod.engine = create_engine(mod.sqlite_url) 1bdfhjlnp
51 calls = [] 1bdfhjlnp
53 new_print = get_testing_print_function(calls) 1bdfhjlnp
55 with patch("builtins.print", new=new_print): 1bdfhjlnp
56 mod.main() 1bdfhjlnp
57 check_calls(calls) 1bdfhjlnp