Coverage for tests/test_advanced/test_decimal/test_tutorial001.py: 100%
15 statements
« prev ^ index » next coverage.py v7.17.2, created at 2026-11-16 00:02 +0000
« prev ^ index » next coverage.py v7.17.2, created at 2026-11-16 00:02 +0000
1import importlib 1abcdefghijklm
2from decimal import Decimal 1abcdefghijklm
3from types import ModuleType 1abcdefghijklm
5import pytest 1abcdefghijklm
6from sqlalchemy import Engine 1abcdefghijklm
8from ...conftest import PrintMock 1abcdefghijklm
11@pytest.fixture( 1abcdefghijklm
12 name="mod",
13 params=[
14 pytest.param("tutorial001"),
15 ],
16)
17def get_module(request: pytest.FixtureRequest, database_engine: Engine) -> ModuleType: 1abcdefghijklm
18 mod = importlib.import_module(f"docs_src.advanced.decimal.{request.param}") 1abcdefghijklm
19 mod.engine = database_engine 1abcdefghijklm
20 return mod 1abcdefghijklm
23expected_calls = [ 1abcdefghijklm
24 [
25 "Hero 1:",
26 {
27 "name": "Deadpond",
28 "age": None,
29 "id": 1,
30 "secret_name": "Dive Wilson",
31 "money": Decimal("1.100"),
32 },
33 ],
34 [
35 "Hero 2:",
36 {
37 "name": "Rusty-Man",
38 "age": 48,
39 "id": 3,
40 "secret_name": "Tommy Sharp",
41 "money": Decimal("2.200"),
42 },
43 ],
44 ["Total money: 3.300"],
45]
48def test_tutorial(print_mock: PrintMock, mod: ModuleType): 1abcdefghijklm
49 mod.main() 1nopqrstuvwxyz
50 assert print_mock.calls == expected_calls 1nopqrstuvwxyz