Coverage for tests / test_tutorial / test_fastapi / test_app_testing / test_tutorial001_tests005.py: 100%

12 statements  

« prev     ^ index     » next       coverage.py v7.13.0, created at 2026-06-10 09:40 +0000

1import importlib 1abcdefgh

2 

3import pytest 1abcdefgh

4from sqlmodel import Session 1abcdefgh

5 

6from docs_src.tutorial.fastapi.app_testing.tutorial001_py310 import main as app_mod 1abcdefgh

7from docs_src.tutorial.fastapi.app_testing.tutorial001_py310 import ( 1abcdefgh

8 test_main_005 as test_mod, 

9) 

10from docs_src.tutorial.fastapi.app_testing.tutorial001_py310.test_main_005 import ( 1abcdefgh

11 session_fixture, 

12) 

13 

14assert session_fixture, "This keeps the session fixture used below" 1abcdefgh

15 

16 

17@pytest.fixture(name="prepare") 1abcdefgh

18def prepare_fixture(clear_sqlmodel): 1abcdefgh

19 # Trigger side effects of registering table models in SQLModel 

20 # This has to be called after clear_sqlmodel, but before the session_fixture 

21 # That's why the extra custom fixture here 

22 importlib.reload(app_mod) 1abcdefgh

23 

24 

25def test_tutorial(prepare, session: Session): 1abcdefgh

26 test_mod.test_create_hero(session) 1ijklmnop