Coverage for tests / test_tutorial / test_connect / test_select / test_tutorial005.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
9expected_calls = [ 1abcdefgh
10 [
11 "Created hero:",
12 {
13 "age": None,
14 "id": 1,
15 "secret_name": "Dive Wilson",
16 "team_id": 2,
17 "name": "Deadpond",
18 },
19 ],
20 [
21 "Created hero:",
22 {
23 "age": 48,
24 "id": 2,
25 "secret_name": "Tommy Sharp",
26 "team_id": 1,
27 "name": "Rusty-Man",
28 },
29 ],
30 [
31 "Created hero:",
32 {
33 "age": None,
34 "id": 3,
35 "secret_name": "Pedro Parqueador",
36 "team_id": None,
37 "name": "Spider-Boy",
38 },
39 ],
40 [
41 "Preventer Hero:",
42 {
43 "age": 48,
44 "id": 2,
45 "secret_name": "Tommy Sharp",
46 "team_id": 1,
47 "name": "Rusty-Man",
48 },
49 "Team:",
50 {"id": 1, "name": "Preventers", "headquarters": "Sharp Tower"},
51 ],
52]
55@pytest.fixture( 1abcdefgh
56 name="module",
57 params=[
58 pytest.param("tutorial005_py310"),
59 ],
60)
61def get_module(request: pytest.FixtureRequest) -> ModuleType: 1abcdefgh
62 module = importlib.import_module( 1abcdefgh
63 f"docs_src.tutorial.connect.select.{request.param}"
64 )
65 module.sqlite_url = "sqlite://" 1abcdefgh
66 module.engine = create_engine(module.sqlite_url) 1abcdefgh
67 return module 1abcdefgh
70def test_tutorial(print_mock: PrintMock, module: ModuleType): 1abcdefgh
71 module.main() 1ijklmnop
72 assert print_mock.calls == expected_calls 1ijklmnop