diff options
Diffstat (limited to 'test/orm/test_inspect.py')
| -rw-r--r-- | test/orm/test_inspect.py | 32 |
1 files changed, 15 insertions, 17 deletions
diff --git a/test/orm/test_inspect.py b/test/orm/test_inspect.py index 1d00fa3af..fc061676b 100644 --- a/test/orm/test_inspect.py +++ b/test/orm/test_inspect.py @@ -8,12 +8,13 @@ from sqlalchemy.orm import class_mapper, synonym, Session, aliased from sqlalchemy.orm.attributes import instance_state, NO_VALUE from sqlalchemy import testing + class TestORMInspection(_fixtures.FixtureTest): @classmethod def setup_mappers(cls): cls._setup_stock_mapping() inspect(cls.classes.User).add_property( - "name_syn",synonym("name") + "name_syn", synonym("name") ) def test_class_mapper(self): @@ -21,7 +22,6 @@ class TestORMInspection(_fixtures.FixtureTest): assert inspect(User) is class_mapper(User) - def test_column_collection_iterate(self): User = self.classes.User user_table = self.tables.users @@ -39,8 +39,7 @@ class TestORMInspection(_fixtures.FixtureTest): user_table = self.tables.users insp = inspect(User) eq_(insp.primary_key, - (user_table.c.id,) - ) + (user_table.c.id,)) def test_local_table(self): User = self.classes.User @@ -64,16 +63,18 @@ class TestORMInspection(_fixtures.FixtureTest): def test_mapper_selectable_fixed(self): from sqlalchemy.orm import mapper + class Foo(object): pass + class Bar(Foo): pass user_table = self.tables.users addresses_table = self.tables.addresses mapper(Foo, user_table, with_polymorphic=(Bar,)) mapper(Bar, addresses_table, inherits=Foo, properties={ - 'address_id': addresses_table.c.id - }) + 'address_id': addresses_table.c.id + }) i1 = inspect(Foo) i2 = inspect(Foo) assert i1.selectable is i2.selectable @@ -238,12 +239,11 @@ class TestORMInspection(_fixtures.FixtureTest): assert not hasattr(prop, 'columns') assert hasattr(prop, 'expression') - def test_extension_types(self): from sqlalchemy.ext.associationproxy import \ - association_proxy, ASSOCIATION_PROXY + association_proxy, ASSOCIATION_PROXY from sqlalchemy.ext.hybrid import hybrid_property, hybrid_method, \ - HYBRID_PROPERTY, HYBRID_METHOD + HYBRID_PROPERTY, HYBRID_METHOD from sqlalchemy import Table, MetaData, Integer, Column from sqlalchemy.orm import mapper from sqlalchemy.orm.interfaces import NOT_EXTENSION @@ -269,15 +269,14 @@ class TestORMInspection(_fixtures.FixtureTest): raise NotImplementedError() t = Table('sometable', MetaData(), - Column('id', Integer, primary_key=True)) + Column('id', Integer, primary_key=True)) mapper(SomeClass, t) mapper(SomeSubClass, inherits=SomeClass) insp = inspect(SomeSubClass) eq_( dict((k, v.extension_type) - for k, v in list(insp.all_orm_descriptors.items()) - ), + for k, v in list(insp.all_orm_descriptors.items())), { 'id': NOT_EXTENSION, 'name': NOT_EXTENSION, @@ -498,7 +497,7 @@ class TestORMInspection(_fixtures.FixtureTest): eq_( (insp.transient, insp.pending, - insp.persistent, insp.detached), + insp.persistent, insp.detached), (True, False, False, False) ) s = Session(testing.db) @@ -506,20 +505,20 @@ class TestORMInspection(_fixtures.FixtureTest): eq_( (insp.transient, insp.pending, - insp.persistent, insp.detached), + insp.persistent, insp.detached), (False, True, False, False) ) s.flush() eq_( (insp.transient, insp.pending, - insp.persistent, insp.detached), + insp.persistent, insp.detached), (False, False, True, False) ) s.expunge(u1) eq_( (insp.transient, insp.pending, - insp.persistent, insp.detached), + insp.persistent, insp.detached), (False, False, False, True) ) @@ -538,4 +537,3 @@ class TestORMInspection(_fixtures.FixtureTest): u1 = User(name='ed') insp = inspect(u1) is_(insp.object, u1) - |
