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