Coverage for tests / test_tutorial / test_python_types / test_tutorial009c.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
2import re 1abdc
3from types import ModuleType 1abdc
4from unittest.mock import patch 1abdc
6import pytest 1abdc
8from ...utils import needs_py310 1abdc
11@pytest.fixture( 1abdc
12 name="module",
13 params=[
14 pytest.param("tutorial009c_py310"),
15 pytest.param("tutorial009c_py310", marks=needs_py310),
16 ],
17)
18def get_module(request: pytest.FixtureRequest): 1abdc
19 mod = importlib.import_module(f"docs_src.python_types.{request.param}") 1abc
20 return mod 1abc
23def test_say_hi(module: ModuleType): 1abdc
24 with patch("builtins.print") as mock_print: 1efg
25 module.say_hi("FastAPI") 1efg
27 mock_print.assert_called_once_with("Hey FastAPI!") 1efg
29 with pytest.raises( 1efg
30 TypeError,
31 match=re.escape("say_hi() missing 1 required positional argument: 'name'"),
32 ):
33 module.say_hi() 1efg