Coverage for tests/test_tutorial/test_update/test_tutorial003_py310_tutorial004_py310.py: 100%
24 statements
« prev ^ index » next coverage.py v7.7.1, created at 2025-03-24 00:02 +0000
« prev ^ index » next coverage.py v7.7.1, created at 2025-03-24 00:02 +0000
1from unittest.mock import patch 1abcdef
3from sqlmodel import create_engine 1abcdef
5from ...conftest import get_testing_print_function, needs_py310 1abcdef
7expected_calls = [ 1abcdef
8 [
9 "Hero 1:",
10 {"id": 2, "name": "Spider-Boy", "secret_name": "Pedro Parqueador", "age": None},
11 ],
12 [
13 "Hero 2:",
14 {
15 "id": 7,
16 "name": "Captain North America",
17 "secret_name": "Esteban Rogelios",
18 "age": 93,
19 },
20 ],
21 [
22 "Updated hero 1:",
23 {
24 "id": 2,
25 "name": "Spider-Youngster",
26 "secret_name": "Pedro Parqueador",
27 "age": 16,
28 },
29 ],
30 [
31 "Updated hero 2:",
32 {
33 "id": 7,
34 "name": "Captain North America Except Canada",
35 "secret_name": "Esteban Rogelios",
36 "age": 110,
37 },
38 ],
39]
42@needs_py310 1abcdef
43def test_tutorial003(clear_sqlmodel): 1abcdef
44 from docs_src.tutorial.update import tutorial003_py310 as mod 1ghij
46 mod.sqlite_url = "sqlite://" 1ghij
47 mod.engine = create_engine(mod.sqlite_url) 1ghij
48 calls = [] 1ghij
50 new_print = get_testing_print_function(calls) 1ghij
52 with patch("builtins.print", new=new_print): 1ghij
53 mod.main() 1ghij
54 assert calls == expected_calls 1ghij
57@needs_py310 1abcdef
58def test_tutorial004(clear_sqlmodel): 1abcdef
59 from docs_src.tutorial.update import tutorial004_py310 as mod 1klmn
61 mod.sqlite_url = "sqlite://" 1klmn
62 mod.engine = create_engine(mod.sqlite_url) 1klmn
63 calls = [] 1klmn
65 new_print = get_testing_print_function(calls) 1klmn
67 with patch("builtins.print", new=new_print): 1klmn
68 mod.main() 1klmn
69 assert calls == expected_calls 1klmn