Skip to content

Instantly share code, notes, and snippets.

@plq

plq/test.py

Last active Aug 29, 2015
Embed
What would you like to do?
sqlalchemy inheritance test case
from sqlalchemy import Column, Integer
from sqlalchemy.ext.declarative import declarative_base
Base = declarative_base()
class C(Base):
__tablename__ = 'C'
id = Column(Integer, primary_key=True)
t = Column(Integer)
__mapper_args__ = {
'polymorphic_on': t,
'polymorphic_identity': 1,
}
assert C().t == 1
class D(C):
__mapper_args__ = {
'polymorphic_identity': 2,
}
assert D().t == 2
class D2(D):
foo = 'bar'
assert D2().t == 2
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.