Coverage for tests/test_tutorial/test_relationship_attributes/test_define_relationship_attributes/test_tutorial001_py39.py: 100%
14 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 1jefghi
3from sqlmodel import create_engine 1jefghi
5from ....conftest import get_testing_print_function, needs_py39 1jefghi
7expected_calls = [ 1efghi
8 [
9 "Created hero:",
10 {
11 "name": "Deadpond",
12 "age": None,
13 "team_id": 1,
14 "id": 1,
15 "secret_name": "Dive Wilson",
16 },
17 ],
18 [
19 "Created hero:",
20 {
21 "name": "Rusty-Man",
22 "age": 48,
23 "team_id": 2,
24 "id": 2,
25 "secret_name": "Tommy Sharp",
26 },
27 ],
28 [
29 "Created hero:",
30 {
31 "name": "Spider-Boy",
32 "age": None,
33 "team_id": None,
34 "id": 3,
35 "secret_name": "Pedro Parqueador",
36 },
37 ],
38]
41@needs_py39 1jefghi
42def test_tutorial(clear_sqlmodel): 1efghi
43 from docs_src.tutorial.relationship_attributes.define_relationship_attributes import ( 1abcd
44 tutorial001_py39 as mod,
45 )
47 mod.sqlite_url = "sqlite://" 1abcd
48 mod.engine = create_engine(mod.sqlite_url) 1abcd
49 calls = [] 1abcd
51 new_print = get_testing_print_function(calls) 1abcd
53 with patch("builtins.print", new=new_print): 1abcd
54 mod.main() 1abcd
55 assert calls == expected_calls 1abcd