Coverage for tests / test_tutorial / test_fastapi / test_app_testing / test_tutorial001_tests_main.py: 100%
15 statements
« prev ^ index » next coverage.py v7.13.0, created at 2026-01-06 21:09 +0000
« prev ^ index » next coverage.py v7.13.0, created at 2026-01-06 21:09 +0000
1import importlib 1abcdefghi
2import subprocess 1abcdefghi
3from pathlib import Path 1abcdefghi
4from types import ModuleType 1abcdefghi
6import pytest 1abcdefghi
8from ....conftest import needs_py310 1abcdefghi
11@pytest.fixture( 1abcdefghi
12 name="module",
13 params=[
14 pytest.param("tutorial001_py39"),
15 pytest.param("tutorial001_py310", marks=needs_py310),
16 ],
17)
18def get_module(request: pytest.FixtureRequest) -> ModuleType: 1abcdefghi
19 module = importlib.import_module( 1abcdefghi
20 f"docs_src.tutorial.fastapi.app_testing.{request.param}.test_main"
21 )
22 return module 1abcdefghi
25def test_run_tests(module: ModuleType): 1abcdefghi
26 test_path = Path(module.__file__).resolve().parent 1jklmnopqr
27 top_level_path = Path(__file__).resolve().parent.parent.parent.parent.parent 1jklmnopqr
28 result = subprocess.run( 1jklmnopqr
29 [
30 "coverage",
31 "run",
32 "--parallel-mode",
33 "-m",
34 "pytest",
35 test_path,
36 ],
37 cwd=top_level_path,
38 capture_output=True,
39 )
40 assert result.returncode == 0, result.stdout.decode("utf-8") 1jklmnopqr