Coverage for tests/test_tutorial/test_fastapi/test_app_testing/test_tutorial001_tests_main.py: 100%
14 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
2import subprocess 1abcdefghijklm
3from pathlib import Path 1abcdefghijklm
4from types import ModuleType 1abcdefghijklm
6import pytest 1abcdefghijklm
9@pytest.fixture( 1abcdefghijklm
10 name="module",
11 params=[
12 pytest.param("tutorial001"),
13 ],
14)
15def get_module(request: pytest.FixtureRequest) -> ModuleType: 1abcdefghijklm
16 module = importlib.import_module( 1abcdefghijklm
17 f"docs_src.tutorial.fastapi.app_testing.{request.param}.test_main"
18 )
19 return module 1abcdefghijklm
22def test_run_tests(module: ModuleType): 1abcdefghijklm
23 test_path = Path(module.__file__).resolve().parent 1nopqrstuvwxyz
24 top_level_path = Path(__file__).resolve().parent.parent.parent.parent.parent 1nopqrstuvwxyz
25 result = subprocess.run( 1nopqrstuvwxyz
26 [
27 "coverage",
28 "run",
29 "--parallel-mode",
30 "-m",
31 "pytest",
32 test_path,
33 ],
34 cwd=top_level_path,
35 capture_output=True,
36 )
37 assert result.returncode == 0, result.stdout.decode("utf-8") 1nopqrstuvwxyz