Coverage for tests / test_tutorial / test_connect / test_create_connected_tables / test_tutorial001.py: 100%
15 statements
« prev ^ index » next coverage.py v7.13.0, created at 2026-11-09 00:02 +0000
« prev ^ index » next coverage.py v7.13.0, created at 2026-11-09 00:02 +0000
1import importlib 1abcdefghi
2from types import ModuleType 1abcdefghi
4import pytest 1abcdefghi
5from sqlalchemy import Engine, inspect 1abcdefghi
6from sqlalchemy.engine.reflection import Inspector 1abcdefghi
9@pytest.fixture( 1abcdefghi
10 name="module",
11 params=[
12 pytest.param("tutorial001_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.connect.create_tables.{request.param}"
18 )
19 module.engine = database_engine 1abcdefghi
20 return module 1abcdefghi
23def test_tutorial001(module: ModuleType): 1abcdefghi
24 module.main() 1jklmnopqr
25 insp: Inspector = inspect(module.engine) 1jklmnopqr
26 assert insp.has_table(str(module.Hero.__tablename__)) 1jklmnopqr
27 assert insp.has_table(str(module.Team.__tablename__)) 1jklmnopqr