Coverage for tests / test_tutorial / test_select / test_tutorial003_tutorial004.py: 100%
22 statements
« prev ^ index » next coverage.py v7.13.0, created at 2026-01-06 21:09 +0000
« prev ^ index » next coverage.py v7.13.0, created at 2026-01-06 21:09 +0000
1import importlib 1abcdefghi
2from types import ModuleType 1abcdefghi
3from typing import Any, Union 1abcdefghi
5import pytest 1abcdefghi
6from sqlmodel import create_engine 1abcdefghi
8from ...conftest import PrintMock, needs_py310 1abcdefghi
11def check_calls(calls: list[list[Union[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) -> ModuleType: 1abcdefghi
36 module = importlib.import_module(f"docs_src.tutorial.select.{request.param}") 1abcdefghi
37 module.sqlite_url = "sqlite://" 1abcdefghi
38 module.engine = create_engine(module.sqlite_url) 1abcdefghi
39 return module 1abcdefghi
42@pytest.mark.parametrize( 1abcdefghi
43 "module",
44 [
45 pytest.param("tutorial003_py39"),
46 pytest.param("tutorial003_py310", marks=needs_py310),
47 ],
48 indirect=True,
49)
50def test_tutorial_003(print_mock: PrintMock, module: ModuleType): 1abcdefghi
51 module.main() 1jlnprtvxz
52 check_calls(print_mock.calls) 1jlnprtvxz
55@pytest.mark.parametrize( 1abcdefghi
56 "module",
57 [
58 pytest.param("tutorial004_py39"),
59 pytest.param("tutorial004_py310", marks=needs_py310),
60 ],
61 indirect=True,
62)
63def test_tutorial_004(print_mock: PrintMock, module: ModuleType): 1abcdefghi
64 module.main() 1kmoqsuwyA
65 check_calls(print_mock.calls) 1kmoqsuwyA