Coverage for tests / test_advanced / test_decimal / test_tutorial001.py: 100%
16 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 decimal import Decimal 1abcdefgh
3from types import ModuleType 1abcdefgh
5import pytest 1abcdefgh
6from sqlmodel import create_engine 1abcdefgh
8from ...conftest import PrintMock 1abcdefgh
11@pytest.fixture( 1abcdefgh
12 name="mod",
13 params=[
14 pytest.param("tutorial001_py310"),
15 ],
16)
17def get_module(request: pytest.FixtureRequest) -> ModuleType: 1abcdefgh
18 mod = importlib.import_module(f"docs_src.advanced.decimal.{request.param}") 1abcdefgh
19 mod.sqlite_url = "sqlite://" 1abcdefgh
20 mod.engine = create_engine(mod.sqlite_url) 1abcdefgh
21 return mod 1abcdefgh
24expected_calls = [ 1abcdefgh
25 [
26 "Hero 1:",
27 {
28 "name": "Deadpond",
29 "age": None,
30 "id": 1,
31 "secret_name": "Dive Wilson",
32 "money": Decimal("1.100"),
33 },
34 ],
35 [
36 "Hero 2:",
37 {
38 "name": "Rusty-Man",
39 "age": 48,
40 "id": 3,
41 "secret_name": "Tommy Sharp",
42 "money": Decimal("2.200"),
43 },
44 ],
45 ["Total money: 3.300"],
46]
49def test_tutorial(print_mock: PrintMock, mod: ModuleType): 1abcdefgh
50 mod.main() 1ijklmnop
51 assert print_mock.calls == expected_calls 1ijklmnop