Coverage for tests / test_tutorial / test_relationship_attributes / test_define_relationship_attributes / test_tutorial001.py: 100%
15 statements
« prev ^ index » next coverage.py v7.13.0, created at 2026-06-10 09:40 +0000
« prev ^ index » next coverage.py v7.13.0, created at 2026-06-10 09:40 +0000
1import importlib 1abcdefgh
2from types import ModuleType 1abcdefgh
4import pytest 1abcdefgh
5from sqlmodel import create_engine 1abcdefgh
7from ....conftest import PrintMock 1abcdefgh
10@pytest.fixture( 1abcdefgh
11 name="mod",
12 params=[
13 pytest.param("tutorial001_py310"),
14 ],
15)
16def get_module(request: pytest.FixtureRequest) -> ModuleType: 1abcdefgh
17 mod = importlib.import_module( 1abcdefgh
18 f"docs_src.tutorial.relationship_attributes.define_relationship_attributes.{request.param}"
19 )
20 mod.sqlite_url = "sqlite://" 1abcdefgh
21 mod.engine = create_engine(mod.sqlite_url) 1abcdefgh
22 return mod 1abcdefgh
25expected_calls = [ 1abcdefgh
26 [
27 "Created hero:",
28 {
29 "name": "Deadpond",
30 "age": None,
31 "team_id": 1,
32 "id": 1,
33 "secret_name": "Dive Wilson",
34 },
35 ],
36 [
37 "Created hero:",
38 {
39 "name": "Rusty-Man",
40 "age": 48,
41 "team_id": 2,
42 "id": 2,
43 "secret_name": "Tommy Sharp",
44 },
45 ],
46 [
47 "Created hero:",
48 {
49 "name": "Spider-Boy",
50 "age": None,
51 "team_id": None,
52 "id": 3,
53 "secret_name": "Pedro Parqueador",
54 },
55 ],
56]
59def test_tutorial(print_mock: PrintMock, mod: ModuleType): 1abcdefgh
60 mod.main() 1ijklmnop
61 assert print_mock.calls == expected_calls 1ijklmnop