Coverage for tests/test_tutorial/test_update/test_tutorial001_py310_tutorial002_py310.py: 100%
24 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 unittest.mock import patch 1abcdefghij
3from sqlmodel import create_engine 1abcdefghij
5from ...conftest import get_testing_print_function, needs_py310 1abcdefghij
7expected_calls = [ 1abcdefghij
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 1abcdefghij
30def test_tutorial001(clear_sqlmodel): 1abcdefghij
31 from docs_src.tutorial.update import tutorial001_py310 as mod 1klmnopqr
33 mod.sqlite_url = "sqlite://" 1klmnopqr
34 mod.engine = create_engine(mod.sqlite_url) 1klmnopqr
35 calls = [] 1klmnopqr
37 new_print = get_testing_print_function(calls) 1klmnopqr
39 with patch("builtins.print", new=new_print): 1klmnopqr
40 mod.main() 1klmnopqr
41 assert calls == expected_calls 1klmnopqr
44@needs_py310 1abcdefghij
45def test_tutorial002(clear_sqlmodel): 1abcdefghij
46 from docs_src.tutorial.update import tutorial002_py310 as mod 1stuvwxyz
48 mod.sqlite_url = "sqlite://" 1stuvwxyz
49 mod.engine = create_engine(mod.sqlite_url) 1stuvwxyz
50 calls = [] 1stuvwxyz
52 new_print = get_testing_print_function(calls) 1stuvwxyz
54 with patch("builtins.print", new=new_print): 1stuvwxyz
55 mod.main() 1stuvwxyz
56 assert calls == expected_calls 1stuvwxyz