Coverage for tests/test_tutorial/test_relationship_attributes/test_back_populates/test_tutorial003.py: 100%
17 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="mod",
11 params=[
12 pytest.param("tutorial003"),
13 ],
14)
15def get_module(request: pytest.FixtureRequest, database_engine: Engine) -> ModuleType: 1abcdefghijklm
16 mod = importlib.import_module( 1abcdefghijklm
17 f"docs_src.tutorial.relationship_attributes.back_populates.{request.param}"
18 )
19 mod.engine = database_engine 1abcdefghijklm
20 return mod 1abcdefghijklm
23def test_tutorial(mod: ModuleType): 1abcdefghijklm
24 mod.main() 1nopqrstuvwxyz
25 insp: Inspector = inspect(mod.engine) 1nopqrstuvwxyz
26 assert insp.has_table(str(mod.Hero.__tablename__)) 1nopqrstuvwxyz
27 assert insp.has_table(str(mod.Weapon.__tablename__)) 1nopqrstuvwxyz
28 assert insp.has_table(str(mod.Power.__tablename__)) 1nopqrstuvwxyz
29 assert insp.has_table(str(mod.Team.__tablename__)) 1nopqrstuvwxyz