-
-
Notifications
You must be signed in to change notification settings - Fork 844
Expand file tree
/
Copy pathtest_tutorial001.py
More file actions
51 lines (44 loc) · 1.2 KB
/
test_tutorial001.py
File metadata and controls
51 lines (44 loc) · 1.2 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
import importlib
import types
from decimal import Decimal
import pytest
from sqlmodel import create_engine
from ...conftest import PrintMock, needs_py310 # Import PrintMock for type hint
expected_calls = [
[
"Hero 1:",
{
"name": "Deadpond",
"age": None,
"id": 1,
"secret_name": "Dive Wilson",
"money": Decimal("1.100"),
},
],
[
"Hero 2:",
{
"name": "Rusty-Man",
"age": 48,
"id": 3,
"secret_name": "Tommy Sharp",
"money": Decimal("2.200"),
},
],
["Total money: 3.300"],
]
@pytest.fixture(
name="module",
params=[
"tutorial001",
pytest.param("tutorial001_py310", marks=needs_py310),
],
)
def get_module(request: pytest.FixtureRequest):
module_name = request.param
return importlib.import_module(f"docs_src.advanced.decimal.{module_name}")
def test_tutorial(print_mock: PrintMock, module: types.ModuleType):
module.sqlite_url = "sqlite://"
module.engine = create_engine(module.sqlite_url)
module.main()
assert print_mock.calls == expected_calls # Use .calls instead of .mock_calls