Coverage for tests/test_tutorial/test_select/test_tutorial001_tutorial002.py: 100%
26 statements
« prev ^ index » next coverage.py v7.6.12, created at 2025-03-07 05:42 +0000
« prev ^ index » next coverage.py v7.6.12, created at 2025-03-07 05:42 +0000
1from typing import Any, Dict, List, Union 1opqrstu
2from unittest.mock import patch 1opqrstu
4from sqlmodel import create_engine 1opqrstu
6from ...conftest import get_testing_print_function 1opqrstu
9def check_calls(calls: List[List[Union[str, Dict[str, Any]]]]): 1opqrstu
10 assert calls[0][0] == { 1abcdefghijklmn
11 "name": "Deadpond",
12 "secret_name": "Dive Wilson",
13 "age": None,
14 "id": 1,
15 }
16 assert calls[1][0] == { 1abcdefghijklmn
17 "name": "Spider-Boy",
18 "secret_name": "Pedro Parqueador",
19 "age": None,
20 "id": 2,
21 }
22 assert calls[2][0] == { 1abcdefghijklmn
23 "name": "Rusty-Man",
24 "secret_name": "Tommy Sharp",
25 "age": 48,
26 "id": 3,
27 }
30def test_tutorial_001(clear_sqlmodel): 1opqrstu
31 from docs_src.tutorial.select import tutorial001 as mod 1acegikm
33 mod.sqlite_url = "sqlite://" 1acegikm
34 mod.engine = create_engine(mod.sqlite_url) 1acegikm
35 calls = [] 1acegikm
37 new_print = get_testing_print_function(calls) 1acegikm
39 with patch("builtins.print", new=new_print): 1acegikm
40 mod.main() 1acegikm
41 check_calls(calls) 1acegikm
44def test_tutorial_002(clear_sqlmodel): 1opqrstu
45 from docs_src.tutorial.select import tutorial002 as mod 1bdfhjln
47 mod.sqlite_url = "sqlite://" 1bdfhjln
48 mod.engine = create_engine(mod.sqlite_url) 1bdfhjln
49 calls = [] 1bdfhjln
51 new_print = get_testing_print_function(calls) 1bdfhjln
53 with patch("builtins.print", new=new_print): 1bdfhjln
54 mod.main() 1bdfhjln
55 check_calls(calls) 1bdfhjln