Coverage for tests / test_tutorial / test_select / test_tutorial003_tutorial004.py: 100%
21 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 {
14 "name": "Deadpond",
15 "secret_name": "Dive Wilson",
16 "age": None,
17 "id": 1,
18 },
19 {
20 "name": "Spider-Boy",
21 "secret_name": "Pedro Parqueador",
22 "age": None,
23 "id": 2,
24 },
25 {
26 "name": "Rusty-Man",
27 "secret_name": "Tommy Sharp",
28 "age": 48,
29 "id": 3,
30 },
31 ]
34@pytest.fixture(name="module") 1abcdefghi
35def get_module(request: pytest.FixtureRequest, database_engine: Engine) -> ModuleType: 1abcdefghi
36 module = importlib.import_module(f"docs_src.tutorial.select.{request.param}") 1abcdefghi
37 module.engine = database_engine 1abcdefghi
38 return module 1abcdefghi
41@pytest.mark.parametrize( 1abcdefghi
42 "module",
43 [
44 pytest.param("tutorial003_py310"),
45 ],
46 indirect=True,
47)
48def test_tutorial_003(print_mock: PrintMock, module: ModuleType): 1abcdefghi
49 module.main() 1jlnprtvxz
50 check_calls(print_mock.calls) 1jlnprtvxz
53@pytest.mark.parametrize( 1abcdefghi
54 "module",
55 [
56 pytest.param("tutorial004_py310"),
57 ],
58 indirect=True,
59)
60def test_tutorial_004(print_mock: PrintMock, module: ModuleType): 1abcdefghi
61 module.main() 1kmoqsuwyA
62 check_calls(print_mock.calls) 1kmoqsuwyA