Coverage for tests / test_tutorial / test_fastapi / test_app_testing / test_tutorial001_tests_main.py: 100%
14 statements
« prev ^ index » next coverage.py v7.13.0, created at 2026-11-09 00:02 +0000
« prev ^ index » next coverage.py v7.13.0, created at 2026-11-09 00:02 +0000
1import importlib 1abcdefghi
2import subprocess 1abcdefghi
3from pathlib import Path 1abcdefghi
4from types import ModuleType 1abcdefghi
6import pytest 1abcdefghi
9@pytest.fixture( 1abcdefghi
10 name="module",
11 params=[
12 pytest.param("tutorial001_py310"),
13 ],
14)
15def get_module(request: pytest.FixtureRequest) -> ModuleType: 1abcdefghi
16 module = importlib.import_module( 1abcdefghi
17 f"docs_src.tutorial.fastapi.app_testing.{request.param}.test_main"
18 )
19 return module 1abcdefghi
22def test_run_tests(module: ModuleType): 1abcdefghi
23 test_path = Path(module.__file__).resolve().parent 1jklmnopqr
24 top_level_path = Path(__file__).resolve().parent.parent.parent.parent.parent 1jklmnopqr
25 result = subprocess.run( 1jklmnopqr
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") 1jklmnopqr