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