Coverage for tests/test_tutorial/test_relationship_attributes/test_define_relationship_attributes/test_tutorial001.py: 100%
13 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 1lghijk
3from sqlmodel import create_engine 1lghijk
5from ....conftest import get_testing_print_function 1lghijk
7expected_calls = [ 1ghijk
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]
41def test_tutorial(clear_sqlmodel): 1lghijk
42 from docs_src.tutorial.relationship_attributes.define_relationship_attributes import ( 1abcdef
43 tutorial001 as mod,
44 )
46 mod.sqlite_url = "sqlite://" 1abcdef
47 mod.engine = create_engine(mod.sqlite_url) 1abcdef
48 calls = [] 1abcdef
50 new_print = get_testing_print_function(calls) 1abcdef
52 with patch("builtins.print", new=new_print): 1abcdef
53 mod.main() 1abcdef
54 assert calls == expected_calls 1abcdef