Coverage for tests/test_tutorial/test_connect/test_update/test_tutorial001.py: 100%
14 statements
« prev ^ index » next coverage.py v7.17.2, created at 2026-11-16 00:02 +0000
« prev ^ index » next coverage.py v7.17.2, created at 2026-11-16 00:02 +0000
1import importlib 1abcdefghijklm
2from types import ModuleType 1abcdefghijklm
4import pytest 1abcdefghijklm
5from sqlalchemy import Engine 1abcdefghijklm
7from ....conftest import PrintMock 1abcdefghijklm
9expected_calls = [ 1abcdefghijklm
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 "Updated hero:",
42 {
43 "age": None,
44 "id": 3,
45 "secret_name": "Pedro Parqueador",
46 "team_id": 1,
47 "name": "Spider-Boy",
48 },
49 ],
50]
53@pytest.fixture( 1abcdefghijklm
54 name="module",
55 params=[
56 pytest.param("tutorial001"),
57 ],
58)
59def get_module(request: pytest.FixtureRequest, database_engine: Engine) -> ModuleType: 1abcdefghijklm
60 module = importlib.import_module( 1abcdefghijklm
61 f"docs_src.tutorial.connect.update.{request.param}"
62 )
63 module.engine = database_engine 1abcdefghijklm
64 return module 1abcdefghijklm
67def test_tutorial(print_mock: PrintMock, module: ModuleType): 1abcdefghijklm
68 module.main() 1nopqrstuvwxyz
69 assert print_mock.calls == expected_calls 1nopqrstuvwxyz