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

12 statements  

« prev     ^ index     » next       coverage.py v7.6.1, created at 2024-09-09 00:02 +0000

1import importlib 1fabcde

2 

3import pytest 1fabcde

4from sqlmodel import Session 1fabcde

5 

6from docs_src.tutorial.fastapi.app_testing.tutorial001 import main as app_mod 1fabcde

7from docs_src.tutorial.fastapi.app_testing.tutorial001 import test_main_005 as test_mod 1fabcde

8from docs_src.tutorial.fastapi.app_testing.tutorial001.test_main_005 import ( 1fabcde

9 session_fixture, 

10) 

11 

12assert session_fixture, "This keeps the session fixture used below" 1fabcde

13 

14 

15@pytest.fixture(name="prepare") 1fabcde

16def prepare_fixture(clear_sqlmodel): 1abcde

17 # Trigger side effects of registering table models in SQLModel 

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

19 # That's why the extra custom fixture here 

20 importlib.reload(app_mod) 1fabcde

21 

22 

23def test_tutorial(prepare, session: Session): 1fabcde

24 test_mod.test_create_hero(session) 1ghijkl