Coverage for tests / test_tutorial / test_create_db_and_table / test_tutorial003.py: 100%

14 statements  

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

1import importlib 1abcdefghi

2from types import ModuleType 1abcdefghi

3 

4import pytest 1abcdefghi

5from sqlalchemy import Engine, inspect 1abcdefghi

6from sqlalchemy.engine.reflection import Inspector 1abcdefghi

7 

8 

9@pytest.fixture( 1abcdefghi

10 name="module", 

11 params=[ 

12 pytest.param("tutorial003_py310"), 

13 ], 

14) 

15def get_module(request: pytest.FixtureRequest, database_engine: Engine) -> ModuleType: 1abcdefghi

16 module = importlib.import_module( 1abcdefghi

17 f"docs_src.tutorial.create_db_and_table.{request.param}" 

18 ) 

19 module.engine = database_engine 1abcdefghi

20 return module 1abcdefghi

21 

22 

23def test_create_db_and_table(module: ModuleType): 1abcdefghi

24 module.create_db_and_tables() 1jklmnopqr

25 insp: Inspector = inspect(module.engine) 1jklmnopqr

26 assert insp.has_table(str(module.Hero.__tablename__)) 1jklmnopqr