Coverage for tests / test_tutorial / test_python_types / test_tutorial009_tutorial009b.py: 100%
16 statements
« prev ^ index » next coverage.py v7.13.3, created at 2026-02-12 18:15 +0000
« prev ^ index » next coverage.py v7.13.3, created at 2026-02-12 18:15 +0000
1import importlib 1abdc
2from types import ModuleType 1abdc
3from unittest.mock import patch 1abdc
5import pytest 1abdc
7from ...utils import needs_py310 1abdc
10@pytest.fixture( 1abdc
11 name="module",
12 params=[
13 pytest.param("tutorial009_py310"),
14 pytest.param("tutorial009_py310", marks=needs_py310),
15 ],
16)
17def get_module(request: pytest.FixtureRequest): 1abdc
18 mod = importlib.import_module(f"docs_src.python_types.{request.param}") 1abc
19 return mod 1abc
22def test_say_hi(module: ModuleType): 1abdc
23 with patch("builtins.print") as mock_print: 1efg
24 module.say_hi("FastAPI") 1efg
25 module.say_hi() 1efg
27 assert mock_print.call_count == 2 1efg
28 call_args = [arg.args for arg in mock_print.call_args_list] 1efg
29 assert call_args == [ 1efg
30 ("Hey FastAPI!",),
31 ("Hello World",),
32 ]