Coverage for tests/test_tutorial/test_update/test_tutorial001_tutorial002.py: 100%
22 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 1rmnopq
3from sqlmodel import create_engine 1rmnopq
5from ...conftest import get_testing_print_function 1rmnopq
7expected_calls = [ 1mnopq
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]
29def test_tutorial001(clear_sqlmodel): 1rmnopq
30 from docs_src.tutorial.update import tutorial001 as mod 1abcdef
32 mod.sqlite_url = "sqlite://" 1abcdef
33 mod.engine = create_engine(mod.sqlite_url) 1abcdef
34 calls = [] 1abcdef
36 new_print = get_testing_print_function(calls) 1abcdef
38 with patch("builtins.print", new=new_print): 1abcdef
39 mod.main() 1abcdef
40 assert calls == expected_calls 1abcdef
43def test_tutorial002(clear_sqlmodel): 1rmnopq
44 from docs_src.tutorial.update import tutorial002 as mod 1ghijkl
46 mod.sqlite_url = "sqlite://" 1ghijkl
47 mod.engine = create_engine(mod.sqlite_url) 1ghijkl
48 calls = [] 1ghijkl
50 new_print = get_testing_print_function(calls) 1ghijkl
52 with patch("builtins.print", new=new_print): 1ghijkl
53 mod.main() 1ghijkl
54 assert calls == expected_calls 1ghijkl