Coverage for tests/test_tutorial/test_connect/test_create_connected_tables/test_tutorial001.py: 100%
15 statements
« prev ^ index » next coverage.py v7.17.2, created at 2026-11-16 00:02 +0000
« prev ^ index » next coverage.py v7.17.2, created at 2026-11-16 00:02 +0000
1import importlib 1abcdefghijklm
2from types import ModuleType 1abcdefghijklm
4import pytest 1abcdefghijklm
5from sqlalchemy import Engine, inspect 1abcdefghijklm
6from sqlalchemy.engine.reflection import Inspector 1abcdefghijklm
9@pytest.fixture( 1abcdefghijklm
10 name="module",
11 params=[
12 pytest.param("tutorial001"),
13 ],
14)
15def get_module(request: pytest.FixtureRequest, database_engine: Engine) -> ModuleType: 1abcdefghijklm
16 module = importlib.import_module( 1abcdefghijklm
17 f"docs_src.tutorial.connect.create_tables.{request.param}"
18 )
19 module.engine = database_engine 1abcdefghijklm
20 return module 1abcdefghijklm
23def test_tutorial001(module: ModuleType): 1abcdefghijklm
24 module.main() 1nopqrstuvwxyz
25 insp: Inspector = inspect(module.engine) 1nopqrstuvwxyz
26 assert insp.has_table(str(module.Hero.__tablename__)) 1nopqrstuvwxyz
27 assert insp.has_table(str(module.Team.__tablename__)) 1nopqrstuvwxyz