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