SQLAlchemy implements a nose plugin that must be present when tests are run.
This plugin is available when SQLAlchemy is installed via setuptools.
+NB: You will need to manually install nose, it is unlikely to be pulled
+ down as a dependency of installing SQLAlchemy.
+
+ Nose can be installed with:
+
+ $ easy_install nose
+
INSTANT TEST RUNNER
-------------------
assert class_mapper(Person).polymorphic_on is Person.__table__.c.type
eq_(class_mapper(Engineer).polymorphic_identity, 'Engineer')
+ def test_mapper_args_classproperty_three(self):
+
+ class Person(Base):
+ __tablename__ = 'people'
+ id = Column(Integer, primary_key=True)
+ discriminator = Column('type', String(50))
+ @classproperty
+ def __mapper_args__(cls):
+ if cls.__name__=='Person':
+ return dict(polymorphic_on=cls.discriminator)
+ else:
+ return dict(polymorphic_identity=cls.__name__)
+
+ class Engineer(Person):
+ pass
+
+ compile_mappers()
+
+ assert class_mapper(Person).polymorphic_on is Person.__table__.c.type
+ eq_(class_mapper(Engineer).polymorphic_identity, 'Engineer')
+
def test_table_args_composite(self):
class MyMixin1: