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-04-06 01:24 +0000
« prev ^ index » next coverage.py v7.13.3, created at 2026-04-06 01:24 +0000
1import importlib 1abcd
2from types import ModuleType 1abcd
3from unittest.mock import patch 1abcd
5import pytest 1abcd
7from ...utils import needs_py310 1abcd
10@pytest.fixture( 1abcd
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): 1abcd
18 mod = importlib.import_module(f"docs_src.python_types.{request.param}") 1mnopqrst
19 return mod 1mnopqrst
22def test_say_hi(module: ModuleType): 1abcd
23 with patch("builtins.print") as mock_print: 1efghijkl
24 module.say_hi("FastAPI") 1efghijkl
25 module.say_hi() 1efghijkl
27 assert mock_print.call_count == 2 1efghijkl
28 call_args = [arg.args for arg in mock_print.call_args_list] 1efghijkl
29 assert call_args == [ 1efghijkl
30 ("Hey FastAPI!",),
31 ("Hello World",),
32 ]