Coverage for tests / test_tutorial / test_select / test_tutorial001_tutorial002.py: 100%
23 statements
« prev ^ index » next coverage.py v7.13.0, created at 2026-11-09 00:02 +0000
« prev ^ index » next coverage.py v7.13.0, created at 2026-11-09 00:02 +0000
1import importlib 1abcdefghi
2from types import ModuleType 1abcdefghi
3from typing import Any 1abcdefghi
5import pytest 1abcdefghi
6from sqlalchemy import Engine 1abcdefghi
8from ...conftest import PrintMock 1abcdefghi
11def check_calls(calls: list[list[str | dict[str, Any]]]): 1abcdefghi
12 assert calls[0][0] == { 1jklmnopqrstuvwxyzA
13 "name": "Deadpond",
14 "secret_name": "Dive Wilson",
15 "age": None,
16 "id": 1,
17 }
18 assert calls[1][0] == { 1jklmnopqrstuvwxyzA
19 "name": "Spider-Boy",
20 "secret_name": "Pedro Parqueador",
21 "age": None,
22 "id": 2,
23 }
24 assert calls[2][0] == { 1jklmnopqrstuvwxyzA
25 "name": "Rusty-Man",
26 "secret_name": "Tommy Sharp",
27 "age": 48,
28 "id": 3,
29 }
32@pytest.fixture(name="module") 1abcdefghi
33def get_module(request: pytest.FixtureRequest, database_engine: Engine) -> ModuleType: 1abcdefghi
34 module = importlib.import_module(f"docs_src.tutorial.select.{request.param}") 1abcdefghi
35 module.engine = database_engine 1abcdefghi
36 return module 1abcdefghi
39@pytest.mark.parametrize( 1abcdefghi
40 "module",
41 [
42 pytest.param("tutorial001_py310"),
43 ],
44 indirect=True,
45)
46def test_tutorial_001(print_mock: PrintMock, module: ModuleType): 1abcdefghi
47 module.main() 1jlnprtvxz
48 check_calls(print_mock.calls) 1jlnprtvxz
51@pytest.mark.parametrize( 1abcdefghi
52 "module",
53 [
54 pytest.param("tutorial002_py310"),
55 ],
56 indirect=True,
57)
58def test_tutorial_002(print_mock: PrintMock, module: ModuleType): 1abcdefghi
59 module.main() 1kmoqsuwyA
60 check_calls(print_mock.calls) 1kmoqsuwyA