Coverage for tests/test_tutorial/test_update/test_tutorial001_py310_tutorial002_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:",
10 {
11 "id": 2,
12 "name": "Spider-Boy",
13 "secret_name": "Pedro Parqueador",
14 "age": None,
15 },
16 ],
17 [
18 "Updated hero:",
19 {
20 "id": 2,
21 "name": "Spider-Boy",
22 "secret_name": "Pedro Parqueador",
23 "age": 16,
24 },
25 ],
26]
29@needs_py310 1abcdef
30def test_tutorial001(clear_sqlmodel): 1abcdef
31 from docs_src.tutorial.update import tutorial001_py310 as mod 1ghij
33 mod.sqlite_url = "sqlite://" 1ghij
34 mod.engine = create_engine(mod.sqlite_url) 1ghij
35 calls = [] 1ghij
37 new_print = get_testing_print_function(calls) 1ghij
39 with patch("builtins.print", new=new_print): 1ghij
40 mod.main() 1ghij
41 assert calls == expected_calls 1ghij
44@needs_py310 1abcdef
45def test_tutorial002(clear_sqlmodel): 1abcdef
46 from docs_src.tutorial.update import tutorial002_py310 as mod 1klmn
48 mod.sqlite_url = "sqlite://" 1klmn
49 mod.engine = create_engine(mod.sqlite_url) 1klmn
50 calls = [] 1klmn
52 new_print = get_testing_print_function(calls) 1klmn
54 with patch("builtins.print", new=new_print): 1klmn
55 mod.main() 1klmn
56 assert calls == expected_calls 1klmn