Coverage for tests / test_tutorial / test_where / test_tutorial011.py: 100%
19 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
10@pytest.fixture( 1abcdefgh
11 name="mod",
12 params=[
13 pytest.param("tutorial011_py310"),
14 ],
15)
16def get_module(request: pytest.FixtureRequest) -> ModuleType: 1abcdefgh
17 mod = importlib.import_module(f"docs_src.tutorial.where.{request.param}") 1abcdefgh
18 mod.sqlite_url = "sqlite://" 1abcdefgh
19 mod.engine = create_engine(mod.sqlite_url) 1abcdefgh
20 return mod 1abcdefgh
23def test_tutorial(print_mock: PrintMock, mod: ModuleType): 1abcdefgh
24 mod.main() 1ijklmnop
25 expected_calls = [ 1ijklmnop
26 [{"id": 5, "name": "Black Lion", "secret_name": "Trevor Challa", "age": 35}],
27 [{"id": 6, "name": "Dr. Weird", "secret_name": "Steve Weird", "age": 36}],
28 [{"id": 3, "name": "Rusty-Man", "secret_name": "Tommy Sharp", "age": 48}],
29 [
30 {
31 "id": 7,
32 "name": "Captain North America",
33 "secret_name": "Esteban Rogelios",
34 "age": 93,
35 }
36 ],
37 ]
38 calls = print_mock.calls 1ijklmnop
39 for call in expected_calls: 1ijklmnop
40 assert call in calls, "This expected item should be in the list" 1ijklmnop
41 # Now that this item was checked, remove it from the list
42 calls.pop(calls.index(call)) 1ijklmnop
43 assert len(calls) == 0, "The list should only have the expected items" 1ijklmnop