Coverage for tests/test_tutorial/test_fastapi/test_app_testing/test_tutorial001_tests006.py: 100%
14 statements
« prev ^ index » next coverage.py v7.6.1, created at 2024-09-09 00:02 +0000
« prev ^ index » next coverage.py v7.6.1, created at 2024-09-09 00:02 +0000
1import importlib 1fabcde
3import pytest 1fabcde
4from fastapi.testclient import TestClient 1fabcde
5from sqlmodel import Session 1fabcde
7from docs_src.tutorial.fastapi.app_testing.tutorial001 import main as app_mod 1fabcde
8from docs_src.tutorial.fastapi.app_testing.tutorial001 import test_main_006 as test_mod 1fabcde
9from docs_src.tutorial.fastapi.app_testing.tutorial001.test_main_006 import ( 1fabcde
10 client_fixture,
11 session_fixture,
12)
14assert session_fixture, "This keeps the session fixture used below" 1fabcde
15assert client_fixture, "This keeps the client fixture used below" 1fabcde
18@pytest.fixture(name="prepare") 1fabcde
19def prepare_fixture(clear_sqlmodel): 1abcde
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) 1fabcde
26def test_tutorial(prepare, session: Session, client: TestClient): 1fabcde
27 test_mod.test_create_hero(client) 1ghijkl