diff options
| author | Mike Bayer <mike_mp@zzzcomputing.com> | 2019-01-06 01:14:26 -0500 |
|---|---|---|
| committer | mike bayer <mike_mp@zzzcomputing.com> | 2019-01-06 17:34:50 +0000 |
| commit | 1e1a38e7801f410f244e4bbb44ec795ae152e04e (patch) | |
| tree | 28e725c5c8188bd0cfd133d1e268dbca9b524978 /test/orm/inheritance/test_selects.py | |
| parent | 404e69426b05a82d905cbb3ad33adafccddb00dd (diff) | |
| download | sqlalchemy-1e1a38e7801f410f244e4bbb44ec795ae152e04e.tar.gz | |
Run black -l 79 against all source files
This is a straight reformat run using black as is, with no edits
applied at all.
The black run will format code consistently, however in
some cases that are prevalent in SQLAlchemy code it produces
too-long lines. The too-long lines will be resolved in the
following commit that will resolve all remaining flake8 issues
including shadowed builtins, long lines, import order, unused
imports, duplicate imports, and docstring issues.
Change-Id: I7eda77fed3d8e73df84b3651fd6cfcfe858d4dc9
Diffstat (limited to 'test/orm/inheritance/test_selects.py')
| -rw-r--r-- | test/orm/inheritance/test_selects.py | 107 |
1 files changed, 67 insertions, 40 deletions
diff --git a/test/orm/inheritance/test_selects.py b/test/orm/inheritance/test_selects.py index 710418b24..cd7e3be40 100644 --- a/test/orm/inheritance/test_selects.py +++ b/test/orm/inheritance/test_selects.py @@ -10,20 +10,23 @@ from sqlalchemy.testing.schema import Table, Column class InheritingSelectablesTest(fixtures.MappedTest): @classmethod def define_tables(cls, metadata): - foo = Table('foo', metadata, - Column('a', String(30), primary_key=1), - Column('b', String(30), nullable=0)) + foo = Table( + "foo", + metadata, + Column("a", String(30), primary_key=1), + Column("b", String(30), nullable=0), + ) - cls.tables.bar = foo.select(foo.c.b == 'bar').alias('bar') - cls.tables.baz = foo.select(foo.c.b == 'baz').alias('baz') + cls.tables.bar = foo.select(foo.c.b == "bar").alias("bar") + cls.tables.baz = foo.select(foo.c.b == "baz").alias("baz") def test_load(self): foo, bar, baz = self.tables.foo, self.tables.bar, self.tables.baz # TODO: add persistence test also - testing.db.execute(foo.insert(), a='not bar', b='baz') - testing.db.execute(foo.insert(), a='also not bar', b='baz') - testing.db.execute(foo.insert(), a='i am bar', b='bar') - testing.db.execute(foo.insert(), a='also bar', b='bar') + testing.db.execute(foo.insert(), a="not bar", b="baz") + testing.db.execute(foo.insert(), a="also not bar", b="baz") + testing.db.execute(foo.insert(), a="i am bar", b="bar") + testing.db.execute(foo.insert(), a="also bar", b="bar") class Foo(fixtures.ComparableEntity): pass @@ -36,24 +39,37 @@ class InheritingSelectablesTest(fixtures.MappedTest): mapper(Foo, foo, polymorphic_on=foo.c.b) - mapper(Baz, baz, - with_polymorphic=('*', - foo.join(baz, foo.c.b == 'baz').alias('baz')), - inherits=Foo, inherit_condition=(foo.c.a == baz.c.a), - inherit_foreign_keys=[baz.c.a], - polymorphic_identity='baz') - - mapper(Bar, bar, - with_polymorphic=('*', - foo.join(bar, foo.c.b == 'bar').alias('bar')), - inherits=Foo, inherit_condition=(foo.c.a == bar.c.a), - inherit_foreign_keys=[bar.c.a], - polymorphic_identity='bar') + mapper( + Baz, + baz, + with_polymorphic=( + "*", + foo.join(baz, foo.c.b == "baz").alias("baz"), + ), + inherits=Foo, + inherit_condition=(foo.c.a == baz.c.a), + inherit_foreign_keys=[baz.c.a], + polymorphic_identity="baz", + ) + + mapper( + Bar, + bar, + with_polymorphic=( + "*", + foo.join(bar, foo.c.b == "bar").alias("bar"), + ), + inherits=Foo, + inherit_condition=(foo.c.a == bar.c.a), + inherit_foreign_keys=[bar.c.a], + polymorphic_identity="bar", + ) s = Session() - assert [Baz(), Baz(), Bar(), Bar()] == s.query( - Foo).order_by(Foo.b.desc()).all() + assert [Baz(), Baz(), Bar(), Bar()] == s.query(Foo).order_by( + Foo.b.desc() + ).all() assert [Bar(), Bar()] == s.query(Bar).all() @@ -62,16 +78,24 @@ class JoinFromSelectPersistenceTest(fixtures.MappedTest): @classmethod def define_tables(cls, metadata): - Table('base', metadata, - Column('id', Integer, primary_key=True, - test_needs_autoincrement=True), - Column('type', String(50))) - Table('child', metadata, - # 1. name of column must be different, so that we rely on - # mapper._table_to_equated to link the two cols - Column('child_id', Integer, ForeignKey( - 'base.id'), primary_key=True), - Column('name', String(50))) + Table( + "base", + metadata, + Column( + "id", Integer, primary_key=True, test_needs_autoincrement=True + ), + Column("type", String(50)), + ) + Table( + "child", + metadata, + # 1. name of column must be different, so that we rely on + # mapper._table_to_equated to link the two cols + Column( + "child_id", Integer, ForeignKey("base.id"), primary_key=True + ), + Column("name", String(50)), + ) @classmethod def setup_classes(cls): @@ -86,20 +110,23 @@ class JoinFromSelectPersistenceTest(fixtures.MappedTest): base, child = self.tables.base, self.tables.child base_select = select([base]).alias() - mapper(Base, base_select, polymorphic_on=base_select.c.type, - polymorphic_identity='base') - mapper(Child, child, inherits=Base, - polymorphic_identity='child') + mapper( + Base, + base_select, + polymorphic_on=base_select.c.type, + polymorphic_identity="base", + ) + mapper(Child, child, inherits=Base, polymorphic_identity="child") sess = Session() # 2. use an id other than "1" here so can't rely on # the two inserts having the same id - c1 = Child(id=12, name='c1') + c1 = Child(id=12, name="c1") sess.add(c1) sess.commit() sess.close() c1 = sess.query(Child).one() - eq_(c1.name, 'c1') + eq_(c1.name, "c1") |
