Coverage for tests/test_tutorial/test_fastapi/test_app_testing/test_tutorial001_tests006.py: 100%
14 statements
« prev ^ index » next coverage.py v7.7.1, created at 2025-03-24 00:02 +0000
« prev ^ index » next coverage.py v7.7.1, created at 2025-03-24 00:02 +0000
1import importlib 1abcdef
3import pytest 1abcdef
4from fastapi.testclient import TestClient 1abcdef
5from sqlmodel import Session 1abcdef
7from docs_src.tutorial.fastapi.app_testing.tutorial001 import main as app_mod 1abcdef
8from docs_src.tutorial.fastapi.app_testing.tutorial001 import test_main_006 as test_mod 1abcdef
9from docs_src.tutorial.fastapi.app_testing.tutorial001.test_main_006 import ( 1abcdef
10 client_fixture,
11 session_fixture,
12)
14assert session_fixture, "This keeps the session fixture used below" 1abcdef
15assert client_fixture, "This keeps the client fixture used below" 1abcdef
18@pytest.fixture(name="prepare") 1abcdef
19def prepare_fixture(clear_sqlmodel): 1abcdef
20 # Trigger side effects of registering table models in SQLModel
21 # This has to be called after clear_sqlmodel, but before the session_fixture
22 # That's why the extra custom fixture here
23 importlib.reload(app_mod) 1abcdef
26def test_tutorial(prepare, session: Session, client: TestClient): 1abcdef
27 test_mod.test_create_hero(client) 1ghijkl