diff options
| author | Mike Bayer <mike_mp@zzzcomputing.com> | 2012-07-28 17:05:50 -0400 |
|---|---|---|
| committer | Mike Bayer <mike_mp@zzzcomputing.com> | 2012-07-28 17:05:50 -0400 |
| commit | 22ba1c43b792953ae6f791512d276739c8c09eae (patch) | |
| tree | bdf9f639b01426a8a2e1c8c61d35533026dd4265 /test | |
| parent | 27913554a85c308d81e6c018669d0246ceecc639 (diff) | |
| download | sqlalchemy-22ba1c43b792953ae6f791512d276739c8c09eae.tar.gz | |
-whitespace bonanza, contd
Diffstat (limited to 'test')
80 files changed, 1383 insertions, 1383 deletions
diff --git a/test/aaa_profiling/test_memusage.py b/test/aaa_profiling/test_memusage.py index 04cf82a15..9e58a10aa 100644 --- a/test/aaa_profiling/test_memusage.py +++ b/test/aaa_profiling/test_memusage.py @@ -272,7 +272,7 @@ class MemUsageTest(EnsureZeroed): x = counter[0] dec = 10 while dec > 0: - # trying to count in binary here, + # trying to count in binary here, # works enough to trip the test case if pow(2, dec) < x: setattr(w1, 'col%d' % dec, counter[0]) @@ -523,7 +523,7 @@ class MemUsageTest(EnsureZeroed): pass mapper(A, table1, properties={ - 'bs':relationship(B, secondary=table3, + 'bs':relationship(B, secondary=table3, backref='as', order_by=table3.c.t1) }) mapper(B, table2) diff --git a/test/aaa_profiling/test_zoomark.py b/test/aaa_profiling/test_zoomark.py index de634d83e..b8ef4090d 100644 --- a/test/aaa_profiling/test_zoomark.py +++ b/test/aaa_profiling/test_zoomark.py @@ -377,7 +377,7 @@ class ZooMarkTest(fixtures.TestBase): def test_profile_2_insert(self): self.test_baseline_2_insert() - @profiling.function_call_count(3118, {'2.7':3333, + @profiling.function_call_count(3118, {'2.7':3333, '2.7+cextension':3109, '2.6':3109}) def test_profile_3_properties(self): self.test_baseline_3_properties() @@ -394,16 +394,16 @@ class ZooMarkTest(fixtures.TestBase): def test_profile_5_aggregates(self): self.test_baseline_5_aggregates() - @profiling.function_call_count(1788, {'2.4': 1118, '3.2':1647, + @profiling.function_call_count(1788, {'2.4': 1118, '3.2':1647, '2.7+cextension':1698}) def test_profile_6_editing(self): self.test_baseline_6_editing() - @profiling.function_call_count(2252, {'2.4': 1673, + @profiling.function_call_count(2252, {'2.4': 1673, '2.6':2412, '2.7':2412, '3.2':2396, - '2.7+cextension':2110, + '2.7+cextension':2110, '2.6+cextension': 2252}) def test_profile_7_multiview(self): self.test_baseline_7_multiview() diff --git a/test/base/test_dependency.py b/test/base/test_dependency.py index 4be3c8390..f3e19982b 100644 --- a/test/base/test_dependency.py +++ b/test/base/test_dependency.py @@ -86,7 +86,7 @@ class DependencySortTest(fixtures.TestBase): eq_(err.cycles, set(['node1', 'node3', 'node2', 'node5', 'node4'])) eq_(err.edges, set([('node3', 'node1'), ('node4', 'node1'), - ('node2', 'node3'), ('node1', 'node2'), + ('node2', 'node3'), ('node1', 'node2'), ('node4','node5'), ('node5', 'node4')])) def test_raise_on_cycle_two(self): @@ -108,7 +108,7 @@ class DependencySortTest(fixtures.TestBase): except exc.CircularDependencyError, err: eq_(err.cycles, set(['node1', 'node3', 'node2'])) eq_(err.edges, set([('node3', 'node1'), ('node2', 'node3'), - ('node3', 'node2'), ('node1', 'node2'), + ('node3', 'node2'), ('node1', 'node2'), ('node2','node4')])) def test_raise_on_cycle_three(self): @@ -224,7 +224,7 @@ class DependencySortTest(fixtures.TestBase): ]) # node6 only became present here once [ticket:2282] was addressed. eq_( - topological.find_cycles(tuples, allnodes), + topological.find_cycles(tuples, allnodes), set(['node1','node2', 'node4', 'node6']) ) @@ -258,23 +258,23 @@ class DependencySortTest(fixtures.TestBase): def test_find_multiple_cycles_four(self): tuples = [ - ('node6', 'node2'), - ('node15', 'node19'), + ('node6', 'node2'), + ('node15', 'node19'), ('node19', 'node2'), ('node4', 'node10'), ('node15', 'node13'), - ('node17', 'node11'), ('node1', 'node19'), ('node15', 'node8'), - ('node6', 'node20'), ('node14', 'node11'), ('node6', 'node14'), + ('node17', 'node11'), ('node1', 'node19'), ('node15', 'node8'), + ('node6', 'node20'), ('node14', 'node11'), ('node6', 'node14'), ('node11', 'node2'), ('node10', 'node20'), ('node1', 'node11'), ('node20', 'node19'), ('node4', 'node20'), ('node15', 'node20'), ('node9', 'node19'), ('node11', 'node10'), ('node11', 'node19'), ('node13', 'node6'), ('node3', 'node15'), ('node9', 'node11'), - ('node4', 'node17'), ('node2', 'node20'), ('node19', 'node10'), + ('node4', 'node17'), ('node2', 'node20'), ('node19', 'node10'), ('node8', 'node4'), ('node11', 'node3'), ('node6', 'node1') ] allnodes = ['node%d' % i for i in xrange(1, 21)] eq_( - topological.find_cycles(tuples, allnodes), - set(['node11', 'node10', 'node13', 'node15', 'node14', 'node17', - 'node19', 'node20', 'node8', 'node1', 'node3', + topological.find_cycles(tuples, allnodes), + set(['node11', 'node10', 'node13', 'node15', 'node14', 'node17', + 'node19', 'node20', 'node8', 'node1', 'node3', 'node2', 'node4', 'node6']) ) diff --git a/test/base/test_events.py b/test/base/test_events.py index 61a4b9c71..57c06c328 100644 --- a/test/base/test_events.py +++ b/test/base/test_events.py @@ -347,7 +347,7 @@ class TestCustomTargets(fixtures.TestBase): ) assert_raises( - exc.InvalidRequestError, + exc.InvalidRequestError, event.listen, listen, "event_one", self.Target ) diff --git a/test/base/test_except.py b/test/base/test_except.py index 18a06b9bd..597f1132b 100644 --- a/test/base/test_except.py +++ b/test/base/test_except.py @@ -5,8 +5,8 @@ from sqlalchemy import exc as sa_exceptions from test.lib import fixtures from test.lib.testing import eq_ -# Py3K -#StandardError = BaseException +# Py3K +#StandardError = BaseException # Py2K from exceptions import StandardError, KeyboardInterrupt, SystemExit # end Py2K @@ -54,7 +54,7 @@ class WrapTest(fixtures.TestBase): def test_tostring_large_dict(self): try: raise sa_exceptions.DBAPIError.instance('this is a message' - , + , {'a': 1, 'b': 2, 'c': 3, 'd': 4, 'e': 5, 'f': 6, 'g': 7, 'h': 8, 'i': 9, 'j': 10, 'k': 11, }, OperationalError(), DatabaseError) @@ -64,8 +64,8 @@ class WrapTest(fixtures.TestBase): def test_tostring_large_list(self): try: - raise sa_exceptions.DBAPIError.instance('this is a message', - [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11,], + raise sa_exceptions.DBAPIError.instance('this is a message', + [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11,], OperationalError(), DatabaseError) except sa_exceptions.DBAPIError, exc: assert str(exc).startswith("(OperationalError) 'this is a " @@ -73,9 +73,9 @@ class WrapTest(fixtures.TestBase): def test_tostring_large_executemany(self): try: - raise sa_exceptions.DBAPIError.instance('this is a message', - [{1: 1}, {1: 1}, {1: 1}, {1: 1}, {1: 1}, {1: 1}, - {1: 1}, {1:1}, {1: 1}, {1: 1},], + raise sa_exceptions.DBAPIError.instance('this is a message', + [{1: 1}, {1: 1}, {1: 1}, {1: 1}, {1: 1}, {1: 1}, + {1: 1}, {1:1}, {1: 1}, {1: 1},], OperationalError(), DatabaseError) except sa_exceptions.DBAPIError, exc: eq_(str(exc) , @@ -84,7 +84,7 @@ class WrapTest(fixtures.TestBase): "1}, {1: 1}, {1: 1}]") try: raise sa_exceptions.DBAPIError.instance('this is a message', [ - {1: 1}, {1: 1}, {1: 1}, {1: 1}, {1: 1}, {1: 1}, {1: 1}, + {1: 1}, {1: 1}, {1: 1}, {1: 1}, {1: 1}, {1: 1}, {1: 1}, {1:1}, {1: 1}, {1: 1}, {1: 1}, ], OperationalError(), DatabaseError) except sa_exceptions.DBAPIError, exc: @@ -95,7 +95,7 @@ class WrapTest(fixtures.TestBase): "bound parameter sets ... {1: 1}, {1: 1}]" ) try: - raise sa_exceptions.DBAPIError.instance('this is a message', + raise sa_exceptions.DBAPIError.instance('this is a message', [ (1, ), (1, ), (1, ), (1, ), (1, ), (1, ), (1, ), (1, ), (1, ), (1, ), @@ -127,7 +127,7 @@ class WrapTest(fixtures.TestBase): def test_db_error_noncompliant_dbapi(self): try: - raise sa_exceptions.DBAPIError.instance('', [], OutOfSpec(), + raise sa_exceptions.DBAPIError.instance('', [], OutOfSpec(), DatabaseError) except sa_exceptions.DBAPIError, e: self.assert_(e.__class__ is sa_exceptions.DBAPIError) diff --git a/test/base/test_utils.py b/test/base/test_utils.py index f827b5879..a9ff7da98 100644 --- a/test/base/test_utils.py +++ b/test/base/test_utils.py @@ -299,7 +299,7 @@ class IdentitySetTest(fixtures.TestBase): ids2 - ids1, IdentitySet([o2, o3]) ) - + ids2 -= ids1 eq_(ids2, IdentitySet([o2, o3])) diff --git a/test/bootstrap/noseplugin.py b/test/bootstrap/noseplugin.py index 89b164cbc..d653fa502 100644 --- a/test/bootstrap/noseplugin.py +++ b/test/bootstrap/noseplugin.py @@ -16,7 +16,7 @@ from test.bootstrap.config import ( _create_testing_engine, _engine_pool, _engine_strategy, _engine_uri, _list_dbs, _log, _prep_testing_database, _require, _reverse_topological, _server_side_cursors, _monkeypatch_cdecimal, _zero_timeout, - _set_table_options, base_config, db, db_label, db_url, file_config, post_configure, + _set_table_options, base_config, db, db_label, db_url, file_config, post_configure, pre_configure) log = logging.getLogger('nose.plugins.sqlalchemy') diff --git a/test/dialect/test_firebird.py b/test/dialect/test_firebird.py index 3241db730..41533dbbd 100644 --- a/test/dialect/test_firebird.py +++ b/test/dialect/test_firebird.py @@ -94,7 +94,7 @@ class DomainReflectionTest(fixtures.TestBase, AssertsExecutionResults): class BuggyDomainReflectionTest(fixtures.TestBase, AssertsExecutionResults): - """Test Firebird domains (and some other reflection bumps), + """Test Firebird domains (and some other reflection bumps), see [ticket:1663] and http://tracker.firebirdsql.org/browse/CORE-356""" __only_on__ = 'firebird' @@ -325,7 +325,7 @@ class TypesTest(fixtures.TestBase): @testing.provide_metadata def test_infinite_float(self): metadata = self.metadata - t = Table('t', metadata, + t = Table('t', metadata, Column('data', Float) ) metadata.create_all() diff --git a/test/dialect/test_maxdb.py b/test/dialect/test_maxdb.py index 8d76529d7..e0c3eafbe 100644 --- a/test/dialect/test_maxdb.py +++ b/test/dialect/test_maxdb.py @@ -10,7 +10,7 @@ from test.lib import * # TODO -# - add "Database" test, a quick check for join behavior on different +# - add "Database" test, a quick check for join behavior on different # max versions # - full max-specific reflection suite # - datetime tests diff --git a/test/dialect/test_mysql.py b/test/dialect/test_mysql.py index 8a880645c..d794fd2b8 100644 --- a/test/dialect/test_mysql.py +++ b/test/dialect/test_mysql.py @@ -26,7 +26,7 @@ class CompileTest(fixtures.TestBase, AssertsCompiledSQL): Column("master_ssl_verify_server_cert", Integer)) x = select([table.c.col1, table.c.master_ssl_verify_server_cert]) - self.assert_compile(x, + self.assert_compile(x, '''SELECT mysql_table.col1, mysql_table.`master_ssl_verify_server_cert` FROM mysql_table''') def test_create_index_simple(self): @@ -66,7 +66,7 @@ class CompileTest(fixtures.TestBase, AssertsCompiledSQL): def test_create_pk_plain(self): m = MetaData() - tbl = Table('testtbl', m, Column('data', String(255)), + tbl = Table('testtbl', m, Column('data', String(255)), PrimaryKeyConstraint('data')) self.assert_compile(schema.CreateTable(tbl), @@ -75,7 +75,7 @@ class CompileTest(fixtures.TestBase, AssertsCompiledSQL): def test_create_pk_with_using(self): m = MetaData() - tbl = Table('testtbl', m, Column('data', String(255)), + tbl = Table('testtbl', m, Column('data', String(255)), PrimaryKeyConstraint('data', mysql_using='btree')) self.assert_compile(schema.CreateTable(tbl), @@ -86,7 +86,7 @@ class CompileTest(fixtures.TestBase, AssertsCompiledSQL): class DialectTest(fixtures.TestBase): __only_on__ = 'mysql' - @testing.only_on(['mysql+mysqldb', 'mysql+oursql'], + @testing.only_on(['mysql+mysqldb', 'mysql+oursql'], 'requires particular SSL arguments') def test_ssl_arguments(self): dialect = testing.db.dialect @@ -98,12 +98,12 @@ class DialectTest(fixtures.TestBase): for k in ('use_unicode', 'found_rows', 'client_flag'): kwarg.pop(k, None) eq_( - kwarg, + kwarg, { - 'passwd': 'tiger', 'db': 'test', - 'ssl': {'ca': '/ca.pem', 'cert': '/cert.pem', - 'key': '/key.pem'}, - 'host': 'localhost', 'user': 'scott', + 'passwd': 'tiger', 'db': 'test', + 'ssl': {'ca': '/ca.pem', 'cert': '/cert.pem', + 'key': '/key.pem'}, + 'host': 'localhost', 'user': 'scott', 'port': 3306 } ) @@ -158,7 +158,7 @@ class TypesTest(fixtures.TestBase, AssertsExecutionResults, AssertsCompiledSQL): columns = [ # column type, args, kwargs, expected ddl - # e.g. Column(Integer(10, unsigned=True)) == + # e.g. Column(Integer(10, unsigned=True)) == # 'INTEGER(10) UNSIGNED' (mysql.MSNumeric, [], {}, 'NUMERIC'), @@ -592,7 +592,7 @@ class TypesTest(fixtures.TestBase, AssertsExecutionResults, AssertsCompiledSQL): # there's a slight assumption here that this test can # complete within the scope of a single second. # if needed, can break out the eq_() just to check for - # timestamps that are within a few seconds of "now" + # timestamps that are within a few seconds of "now" # using timedelta. now = testing.db.execute("select now()").scalar() @@ -730,7 +730,7 @@ class TypesTest(fixtures.TestBase, AssertsExecutionResults, AssertsCompiledSQL): enum_table.drop(checkfirst=True) enum_table.create() - assert_raises(exc.DBAPIError, enum_table.insert().execute, + assert_raises(exc.DBAPIError, enum_table.insert().execute, e1=None, e2=None, e3=None, e4=None) assert_raises(exc.StatementError, enum_table.insert().execute, @@ -745,8 +745,8 @@ class TypesTest(fixtures.TestBase, AssertsExecutionResults, AssertsCompiledSQL): res = enum_table.select().execute().fetchall() - expected = [(None, 'a', 'a', None, 'a', None, None, None), - ('a', 'a', 'a', 'a', 'a', 'a', 'a', "'a'"), + expected = [(None, 'a', 'a', None, 'a', None, None, None), + ('a', 'a', 'a', 'a', 'a', 'a', 'a', "'a'"), ('b', 'b', 'b', 'b', 'b', 'b', 'b', 'b')] # This is known to fail with MySQLDB 1.2.2 beta versions @@ -786,8 +786,8 @@ class TypesTest(fixtures.TestBase, AssertsExecutionResults, AssertsCompiledSQL): t1.insert().execute(value=u'drôle', value2=u'drôle') t1.insert().execute(value=u'réveillé', value2=u'réveillé') t1.insert().execute(value=u'S’il', value2=u'S’il') - eq_(t1.select().order_by(t1.c.id).execute().fetchall(), - [(1, u'drôle', u'drôle'), (2, u'réveillé', u'réveillé'), + eq_(t1.select().order_by(t1.c.id).execute().fetchall(), + [(1, u'drôle', u'drôle'), (2, u'réveillé', u'réveillé'), (3, u'S’il', u'S’il')] ) @@ -802,7 +802,7 @@ class TypesTest(fixtures.TestBase, AssertsExecutionResults, AssertsCompiledSQL): assert t2.c.value.type.enums[0:2] == \ (u'réveillé', u'drôle') #, u'S’il') # eh ? assert t2.c.value2.type.enums[0:2] == \ - (u'réveillé', u'drôle') #, u'S’il') # eh ? + (u'réveillé', u'drôle') #, u'S’il') # eh ? finally: metadata.drop_all() @@ -1153,7 +1153,7 @@ class SQLTest(fixtures.TestBase, AssertsCompiledSQL): ) eq_(gen(prefixes=['ALL']), 'SELECT ALL q') - eq_(gen(prefixes=['DISTINCTROW']), + eq_(gen(prefixes=['DISTINCTROW']), 'SELECT DISTINCTROW q') # Interaction with MySQL prefix extensions @@ -1182,7 +1182,7 @@ class SQLTest(fixtures.TestBase, AssertsCompiledSQL): ) self.assert_compile( - select(['q'], distinct='ALL', + select(['q'], distinct='ALL', prefixes=['HIGH_PRIORITY', 'SQL_SMALL_RESULT']), 'SELECT HIGH_PRIORITY SQL_SMALL_RESULT ALL q' ) @@ -1211,7 +1211,7 @@ class SQLTest(fixtures.TestBase, AssertsCompiledSQL): ) self.assert_compile( select([t]).limit(10), - "SELECT t.col1, t.col2 FROM t LIMIT %s", + "SELECT t.col1, t.col2 FROM t LIMIT %s", {'param_1':10}) self.assert_compile( @@ -1232,9 +1232,9 @@ class SQLTest(fixtures.TestBase, AssertsCompiledSQL): ): type_ = sqltypes.to_instance(type_) assert_raises_message( - exc.CompileError, + exc.CompileError, "VARCHAR requires a length on dialect mysql", - type_.compile, + type_.compile, dialect=mysql.dialect()) t1 = Table('sometable', MetaData(), @@ -1289,7 +1289,7 @@ class SQLTest(fixtures.TestBase, AssertsCompiledSQL): # 'SIGNED INTEGER' is a bigint, so this is ok. (m.MSBigInteger, "CAST(t.col AS SIGNED INTEGER)"), (m.MSBigInteger(unsigned=False), "CAST(t.col AS SIGNED INTEGER)"), - (m.MSBigInteger(unsigned=True), + (m.MSBigInteger(unsigned=True), "CAST(t.col AS UNSIGNED INTEGER)"), (m.MSBit, "t.col"), @@ -1412,7 +1412,7 @@ class SQLTest(fixtures.TestBase, AssertsCompiledSQL): tname = 'zyrenian_zyme_zyzzogeton_zyzzogeton' cname = 'zyrenian_zyme_zyzzogeton_zo' - t1 = Table(tname, MetaData(), + t1 = Table(tname, MetaData(), Column(cname, Integer, index=True), ) ix1 = list(t1.indexes)[0] diff --git a/test/dialect/test_postgresql.py b/test/dialect/test_postgresql.py index b50b0dcbb..a039b0221 100644 --- a/test/dialect/test_postgresql.py +++ b/test/dialect/test_postgresql.py @@ -155,7 +155,7 @@ class CompileTest(fixtures.TestBase, AssertsCompiledSQL): def test_create_index_with_ops(self): m = MetaData() tbl = Table('testtbl', m, - Column('data', String), + Column('data', String), Column('data2', Integer, key='d2')) idx = Index('test_idx1', tbl.c.data, @@ -269,7 +269,7 @@ class CompileTest(fixtures.TestBase, AssertsCompiledSQL): Column("variadic", Integer)) x = select([table.c.col1, table.c.variadic]) - self.assert_compile(x, + self.assert_compile(x, '''SELECT pg_table.col1, pg_table."variadic" FROM pg_table''') def test_from_only(self): @@ -382,7 +382,7 @@ class FloatCoercionTest(fixtures.TablesTest, AssertsExecutionResults): @testing.provide_metadata def test_arrays(self): metadata = self.metadata - t1 = Table('t', metadata, + t1 = Table('t', metadata, Column('x', postgresql.ARRAY(Float)), Column('y', postgresql.ARRAY(REAL)), Column('z', postgresql.ARRAY(postgresql.DOUBLE_PRECISION)), @@ -392,7 +392,7 @@ class FloatCoercionTest(fixtures.TablesTest, AssertsExecutionResults): t1.insert().execute(x=[5], y=[5], z=[6], q=[decimal.Decimal("6.4")]) row = t1.select().execute().first() eq_( - row, + row, ([5], [5], [6], [decimal.Decimal("6.4")]) ) @@ -465,7 +465,7 @@ class EnumTest(fixtures.TestBase, AssertsExecutionResults, AssertsCompiledSQL): metadata = MetaData(testing.db) t1 = Table('table', metadata, Column('id', Integer, primary_key=True), - Column('value', + Column('value', Enum(u'réveillé', u'drôle', u'S’il', name='onetwothreetype')) ) @@ -475,7 +475,7 @@ class EnumTest(fixtures.TestBase, AssertsExecutionResults, AssertsCompiledSQL): t1.insert().execute(value=u'drôle') t1.insert().execute(value=u'réveillé') t1.insert().execute(value=u'S’il') - eq_(t1.select().order_by(t1.c.id).execute().fetchall(), + eq_(t1.select().order_by(t1.c.id).execute().fetchall(), [(1, u'drôle'), (2, u'réveillé'), (3, u'S’il')] ) m2 = MetaData(testing.db) @@ -504,11 +504,11 @@ class EnumTest(fixtures.TestBase, AssertsExecutionResults, AssertsCompiledSQL): def test_disable_create(self): metadata = self.metadata - e1 = postgresql.ENUM('one', 'two', 'three', + e1 = postgresql.ENUM('one', 'two', 'three', name="myenum", create_type=False) - t1 = Table('e1', metadata, + t1 = Table('e1', metadata, Column('c1', e1) ) # table can be created separately @@ -529,7 +529,7 @@ class EnumTest(fixtures.TestBase, AssertsExecutionResults, AssertsCompiledSQL): """ metadata = self.metadata - e1 = Enum('one', 'two', 'three', + e1 = Enum('one', 'two', 'three', name="myenum") t1 = Table('e1', metadata, Column('c1', e1) @@ -666,9 +666,9 @@ class NumericInterpretationTest(fixtures.TestBase): @testing.provide_metadata def test_numeric_default(self): metadata = self.metadata - # pg8000 appears to fail when the value is 0, + # pg8000 appears to fail when the value is 0, # returns an int instead of decimal. - t =Table('t', metadata, + t =Table('t', metadata, Column('id', Integer, primary_key=True), Column('nd', Numeric(asdecimal=True), default=1), Column('nf', Numeric(asdecimal=False), default=1), @@ -1245,8 +1245,8 @@ class DistinctOnTest(fixtures.TestBase, AssertsCompiledSQL): __dialect__ = postgresql.dialect() def setup(self): - self.table = Table('t', MetaData(), - Column('id',Integer, primary_key=True), + self.table = Table('t', MetaData(), + Column('id',Integer, primary_key=True), Column('a', String), Column('b', String), ) @@ -1278,7 +1278,7 @@ class DistinctOnTest(fixtures.TestBase, AssertsCompiledSQL): def test_on_columns_inline_list(self): self.assert_compile( - select([self.table], + select([self.table], distinct=[self.table.c.a, self.table.c.b]). order_by(self.table.c.a, self.table.c.b), "SELECT DISTINCT ON (t.a, t.b) t.id, " @@ -1538,28 +1538,28 @@ class ReflectionTest(fixtures.TestBase): m1 = MetaData() - t2_schema = Table('some_other_table', - m1, - schema="test_schema_2", - autoload=True, + t2_schema = Table('some_other_table', + m1, + schema="test_schema_2", + autoload=True, autoload_with=conn) - t1_schema = Table('some_table', - m1, - schema="test_schema", + t1_schema = Table('some_table', + m1, + schema="test_schema", autoload=True, autoload_with=conn) - t2_no_schema = Table('some_other_table', - m1, - autoload=True, + t2_no_schema = Table('some_other_table', + m1, + autoload=True, autoload_with=conn) - t1_no_schema = Table('some_table', - m1, - autoload=True, + t1_no_schema = Table('some_table', + m1, + autoload=True, autoload_with=conn) - # OK, this because, "test_schema" is + # OK, this because, "test_schema" is # in the search path, and might as well be # the default too. why would we assign # a "schema" to the Table ? @@ -1624,7 +1624,7 @@ class ReflectionTest(fixtures.TestBase): @testing.provide_metadata def test_index_reflection_modified(self): - """reflect indexes when a column name has changed - PG 9 + """reflect indexes when a column name has changed - PG 9 does not update the name of the column in the index def. [ticket:2141] @@ -1721,7 +1721,7 @@ class MiscTest(fixtures.TestBase, AssertsExecutionResults, AssertsCompiledSQL): current_encoding = c.connection.connection.encoding c.close() - # attempt to use an encoding that's not + # attempt to use an encoding that's not # already set if current_encoding == 'UTF8': test_encoding = 'LATIN1' @@ -1992,9 +1992,9 @@ class ArrayTest(fixtures.TestBase, AssertsExecutionResults): for v in value ] - arrtable = Table('arrtable', metadata, - Column('id', Integer, primary_key=True), - Column('intarr',postgresql.ARRAY(Integer)), + arrtable = Table('arrtable', metadata, + Column('id', Integer, primary_key=True), + Column('intarr',postgresql.ARRAY(Integer)), Column('strarr',postgresql.ARRAY(Unicode())), Column('dimarr', ProcValue) ) @@ -2064,15 +2064,15 @@ class ArrayTest(fixtures.TestBase, AssertsExecutionResults): metadata.create_all() testing.db.execute(t1.insert(), id=1, data=["1","2","3"], data2=[5.4, 5.6]) testing.db.execute(t1.insert(), id=2, data=["4", "5", "6"], data2=[1.0]) - testing.db.execute(t1.insert(), id=3, data=[["4", "5"], ["6", "7"]], + testing.db.execute(t1.insert(), id=3, data=[["4", "5"], ["6", "7"]], data2=[[5.4, 5.6], [1.0, 1.1]]) r = testing.db.execute(t1.select().order_by(t1.c.id)).fetchall() eq_( - r, + r, [ - (1, ('1', '2', '3'), (5.4, 5.6)), - (2, ('4', '5', '6'), (1.0,)), + (1, ('1', '2', '3'), (5.4, 5.6)), + (2, ('4', '5', '6'), (1.0,)), (3, (('4', '5'), ('6', '7')), ((5.4, 5.6), (1.0, 1.1))) ] ) @@ -2329,7 +2329,7 @@ class UUIDTest(fixtures.TestBase): def test_uuid_string(self): import uuid self._test_round_trip( - Table('utable', MetaData(), + Table('utable', MetaData(), Column('data', postgresql.UUID()) ), str(uuid.uuid4()), @@ -2343,7 +2343,7 @@ class UUIDTest(fixtures.TestBase): def test_uuid_uuid(self): import uuid self._test_round_trip( - Table('utable', MetaData(), + Table('utable', MetaData(), Column('data', postgresql.UUID(as_uuid=True)) ), uuid.uuid4(), @@ -2402,16 +2402,16 @@ class MatchTest(fixtures.TestBase, AssertsCompiledSQL): {'id': 2, 'description': 'Ruby'}]) matchtable.insert().execute([{'id': 1, 'title' : 'Agile Web Development with Rails' - , 'category_id': 2}, + , 'category_id': 2}, {'id': 2, 'title': 'Dive Into Python', - 'category_id': 1}, + 'category_id': 1}, {'id': 3, 'title' : "Programming Matz's Ruby", - 'category_id': 2}, + 'category_id': 2}, {'id': 4, 'title' : 'The Definitive Guide to Django', - 'category_id': 1}, + 'category_id': 1}, {'id': 5, 'title' : 'Python in a Nutshell', 'category_id': 1}]) @@ -2504,12 +2504,12 @@ class TupleTest(fixtures.TestBase): testing.db.execute( select([ tuple_( - literal_column("'a'"), + literal_column("'a'"), literal_column("'b'") ).\ in_([ tuple_(*[ - literal_column("'%s'" % letter) + literal_column("'%s'" % letter) for letter in elem ]) for elem in test ]) diff --git a/test/dialect/test_pyodbc.py b/test/dialect/test_pyodbc.py index c2aec726b..52d6bc7c4 100644 --- a/test/dialect/test_pyodbc.py +++ b/test/dialect/test_pyodbc.py @@ -12,6 +12,6 @@ class PyODBCTest(fixtures.TestBase): ("crap.crap.crap", ()), ]: eq_( - connector._parse_dbapi_version(vers), + connector._parse_dbapi_version(vers), expected )
\ No newline at end of file diff --git a/test/dialect/test_sqlite.py b/test/dialect/test_sqlite.py index d41d87899..4ce3d8fb6 100644 --- a/test/dialect/test_sqlite.py +++ b/test/dialect/test_sqlite.py @@ -75,11 +75,11 @@ class TestTypes(fixtures.TestBase, AssertsExecutionResults): t.create(engine) try: engine.execute(t.insert(), {'d1': datetime.date(2010, 5, - 10), + 10), 'd2': datetime.datetime( 2010, 5, 10, 12, 15, 25, )}) row = engine.execute(t.select()).first() - eq_(row, (1, datetime.date(2010, 5, 10), + eq_(row, (1, datetime.date(2010, 5, 10), datetime.datetime( 2010, 5, 10, 12, 15, 25, ))) r = engine.execute(func.current_date()).scalar() assert isinstance(r, basestring) @@ -336,7 +336,7 @@ class DefaultsTest(fixtures.TestBase, AssertsCompiledSQL): m2 = MetaData(db) t2 = Table('r_defaults', m2, autoload=True) self.assert_compile( - CreateTable(t2), + CreateTable(t2), "CREATE TABLE r_defaults (data VARCHAR(40) " "DEFAULT 'my_default', val INTEGER DEFAULT 0 " "NOT NULL)" @@ -346,7 +346,7 @@ class DefaultsTest(fixtures.TestBase, AssertsCompiledSQL): @testing.provide_metadata def test_boolean_default(self): - t= Table("t", self.metadata, + t= Table("t", self.metadata, Column("x", Boolean, server_default=sql.false())) t.create(testing.db) testing.db.execute(t.insert()) @@ -399,7 +399,7 @@ class DialectTest(fixtures.TestBase, AssertsExecutionResults): CREATE TABLE "django_admin_log" ( "id" integer NOT NULL PRIMARY KEY, "action_time" datetime NOT NULL, - "content_type_id" integer NULL + "content_type_id" integer NULL REFERENCES "django_content_type" ("id"), "object_id" text NULL, "change_message" text NOT NULL @@ -542,26 +542,26 @@ class SQLTest(fixtures.TestBase, AssertsCompiledSQL): sql.false(), "0" ) self.assert_compile( - sql.true(), + sql.true(), "1" ) def test_constraints_with_schemas(self): metadata = MetaData() - t1 = Table('t1', metadata, + t1 = Table('t1', metadata, Column('id', Integer, primary_key=True), schema='master') - t2 = Table('t2', metadata, + t2 = Table('t2', metadata, Column('id', Integer, primary_key=True), Column('t1_id', Integer, ForeignKey('master.t1.id')), schema='master' ) - t3 = Table('t3', metadata, + t3 = Table('t3', metadata, Column('id', Integer, primary_key=True), Column('t1_id', Integer, ForeignKey('master.t1.id')), schema='alternate' ) - t4 = Table('t4', metadata, + t4 = Table('t4', metadata, Column('id', Integer, primary_key=True), Column('t1_id', Integer, ForeignKey('master.t1.id')), ) @@ -692,17 +692,17 @@ class MatchTest(fixtures.TestBase, AssertsCompiledSQL): metadata = MetaData(testing.db) testing.db.execute(""" CREATE VIRTUAL TABLE cattable using FTS3 ( - id INTEGER NOT NULL, - description VARCHAR(50), + id INTEGER NOT NULL, + description VARCHAR(50), PRIMARY KEY (id) ) """) cattable = Table('cattable', metadata, autoload=True) testing.db.execute(""" CREATE VIRTUAL TABLE matchtable using FTS3 ( - id INTEGER NOT NULL, + id INTEGER NOT NULL, title VARCHAR(200), - category_id INTEGER NOT NULL, + category_id INTEGER NOT NULL, PRIMARY KEY (id) ) """) @@ -867,7 +867,7 @@ class ReflectFKConstraintTest(fixtures.TestBase): def test_name_not_none(self): # we don't have names for PK constraints, - # it appears we get back None in the pragma for + # it appears we get back None in the pragma for # FKs also (also it doesn't even appear to be documented on sqlite's docs # at http://www.sqlite.org/pragma.html#pragma_foreign_key_list # how did we ever know that's the "name" field ??) diff --git a/test/engine/test_ddlevents.py b/test/engine/test_ddlevents.py index c1616fcfb..f910dd5ea 100644 --- a/test/engine/test_ddlevents.py +++ b/test/engine/test_ddlevents.py @@ -264,16 +264,16 @@ class DDLExecutionTest(fixtures.TestBase): def test_deprecated_append_ddl_listener_table(self): metadata, users, engine = self.metadata, self.users, self.engine canary = [] - users.append_ddl_listener('before-create', + users.append_ddl_listener('before-create', lambda e, t, b:canary.append('mxyzptlk') ) - users.append_ddl_listener('after-create', + users.append_ddl_listener('after-create', lambda e, t, b:canary.append('klptzyxm') ) - users.append_ddl_listener('before-drop', + users.append_ddl_listener('before-drop', lambda e, t, b:canary.append('xyzzy') ) - users.append_ddl_listener('after-drop', + users.append_ddl_listener('after-drop', lambda e, t, b:canary.append('fnord') ) @@ -293,16 +293,16 @@ class DDLExecutionTest(fixtures.TestBase): def test_deprecated_append_ddl_listener_metadata(self): metadata, users, engine = self.metadata, self.users, self.engine canary = [] - metadata.append_ddl_listener('before-create', + metadata.append_ddl_listener('before-create', lambda e, t, b, tables=None:canary.append('mxyzptlk') ) - metadata.append_ddl_listener('after-create', + metadata.append_ddl_listener('after-create', lambda e, t, b, tables=None:canary.append('klptzyxm') ) - metadata.append_ddl_listener('before-drop', + metadata.append_ddl_listener('before-drop', lambda e, t, b, tables=None:canary.append('xyzzy') ) - metadata.append_ddl_listener('after-drop', + metadata.append_ddl_listener('after-drop', lambda e, t, b, tables=None:canary.append('fnord') ) @@ -541,7 +541,7 @@ class DDLTest(fixtures.TestBase, AssertsCompiledSQL): assert DDL('').execute_if(callable_=lambda d, y,z, **kw: True).\ _should_execute(tbl, cx) assert(DDL('').execute_if( - callable_=lambda d, y,z, **kw: z.engine.name + callable_=lambda d, y,z, **kw: z.engine.name != 'bogus'). _should_execute(tbl, cx)) diff --git a/test/engine/test_parseconnect.py b/test/engine/test_parseconnect.py index dcb149be8..622df3fdf 100644 --- a/test/engine/test_parseconnect.py +++ b/test/engine/test_parseconnect.py @@ -140,7 +140,7 @@ pool_timeout=10 assert e.echo is True for param, values in [ - ('convert_unicode', ('true', 'false', 'force')), + ('convert_unicode', ('true', 'false', 'force')), ('echo', ('true', 'false', 'debug')), ('echo_pool', ('true', 'false', 'debug')), ('use_native_unicode', ('true', 'false')), @@ -191,7 +191,7 @@ pool_timeout=10 assert e.pool._reset_on_return is expected assert_raises( - exc.ArgumentError, + exc.ArgumentError, create_engine, "postgresql://", pool_reset_on_return='hi', module=dbapi, _initialize=False @@ -250,7 +250,7 @@ pool_timeout=10 every backend. """ - # pretend pysqlite throws the + # pretend pysqlite throws the # "Cannot operate on a closed database." error # on connect. IRL we'd be getting Oracle's "shutdown in progress" diff --git a/test/engine/test_reconnect.py b/test/engine/test_reconnect.py index da9e54292..360a20eb2 100644 --- a/test/engine/test_reconnect.py +++ b/test/engine/test_reconnect.py @@ -58,7 +58,7 @@ class MockReconnectTest(fixtures.TestBase): # note - using straight create_engine here # since we are testing gc db = create_engine( - 'postgresql://foo:bar@localhost/test', + 'postgresql://foo:bar@localhost/test', module=dbapi, _initialize=False) # monkeypatch disconnect checker @@ -205,7 +205,7 @@ class CursorErrTest(fixtures.TestBase): dbapi = MDBAPI() db = testing_engine( - 'postgresql://foo:bar@localhost/test', + 'postgresql://foo:bar@localhost/test', options=dict(module=dbapi, _initialize=False)) def test_cursor_explode(self): @@ -451,7 +451,7 @@ class RecycleTest(fixtures.TestBase): # set the pool recycle down to 1. # we aren't doing this inline with the - # engine create since cx_oracle takes way + # engine create since cx_oracle takes way # too long to create the 1st connection and don't # want to build a huge delay into this test. diff --git a/test/engine/test_reflection.py b/test/engine/test_reflection.py index be2acb1f3..2713bd80b 100644 --- a/test/engine/test_reflection.py +++ b/test/engine/test_reflection.py @@ -135,11 +135,11 @@ class ReflectionTest(fixtures.TestBase, ComparesTables): t2 = Table('t', m2, old_z, old_q) eq_(t2.primary_key.columns, (t2.c.z, )) t2 = Table('t', m2, old_y, - extend_existing=True, - autoload=True, + extend_existing=True, + autoload=True, autoload_with=testing.db) eq_( - set(t2.columns.keys()), + set(t2.columns.keys()), set(['x', 'y', 'z', 'q', 'id']) ) eq_(t2.primary_key.columns, (t2.c.id, )) @@ -150,11 +150,11 @@ class ReflectionTest(fixtures.TestBase, ComparesTables): m3 = MetaData() t3 = Table('t', m3, Column('z', Integer)) - t3 = Table('t', m3, extend_existing=False, - autoload=True, + t3 = Table('t', m3, extend_existing=False, + autoload=True, autoload_with=testing.db) eq_( - set(t3.columns.keys()), + set(t3.columns.keys()), set(['z']) ) @@ -165,12 +165,12 @@ class ReflectionTest(fixtures.TestBase, ComparesTables): t4 = Table('t', m4, old_z, old_q) eq_(t4.primary_key.columns, (t4.c.z, )) t4 = Table('t', m4, old_y, - extend_existing=True, - autoload=True, + extend_existing=True, + autoload=True, autoload_replace=False, autoload_with=testing.db) eq_( - set(t4.columns.keys()), + set(t4.columns.keys()), set(['x', 'y', 'z', 'q', 'id']) ) eq_(t4.primary_key.columns, (t4.c.id, )) @@ -202,9 +202,9 @@ class ReflectionTest(fixtures.TestBase, ComparesTables): @testing.provide_metadata def test_autoload_replace_foreign_key_nonpresent(self): - """test autoload_replace=False with col plus FK + """test autoload_replace=False with col plus FK establishes the FK not present in the DB. - + """ a = Table('a', self.metadata, Column('id', Integer, primary_key=True)) b = Table('b', self.metadata, Column('id', Integer, primary_key=True), @@ -214,8 +214,8 @@ class ReflectionTest(fixtures.TestBase, ComparesTables): m2 = MetaData() b2 = Table('b', m2, Column('a_id', Integer, sa.ForeignKey('a.id'))) a2 = Table('a', m2, autoload=True, autoload_with=testing.db) - b2 = Table('b', m2, extend_existing=True, autoload=True, - autoload_with=testing.db, + b2 = Table('b', m2, extend_existing=True, autoload=True, + autoload_with=testing.db, autoload_replace=False) assert b2.c.id is not None @@ -225,9 +225,9 @@ class ReflectionTest(fixtures.TestBase, ComparesTables): @testing.provide_metadata def test_autoload_replace_foreign_key_ispresent(self): """test autoload_replace=False with col plus FK mirroring - DB-reflected FK skips the reflected FK and installs + DB-reflected FK skips the reflected FK and installs the in-python one only. - + """ a = Table('a', self.metadata, Column('id', Integer, primary_key=True)) b = Table('b', self.metadata, Column('id', Integer, primary_key=True), @@ -237,8 +237,8 @@ class ReflectionTest(fixtures.TestBase, ComparesTables): m2 = MetaData() b2 = Table('b', m2, Column('a_id', Integer, sa.ForeignKey('a.id'))) a2 = Table('a', m2, autoload=True, autoload_with=testing.db) - b2 = Table('b', m2, extend_existing=True, autoload=True, - autoload_with=testing.db, + b2 = Table('b', m2, extend_existing=True, autoload=True, + autoload_with=testing.db, autoload_replace=False) assert b2.c.id is not None @@ -259,8 +259,8 @@ class ReflectionTest(fixtures.TestBase, ComparesTables): m2 = MetaData() b2 = Table('b', m2, Column('a_id', Integer)) a2 = Table('a', m2, autoload=True, autoload_with=testing.db) - b2 = Table('b', m2, extend_existing=True, autoload=True, - autoload_with=testing.db, + b2 = Table('b', m2, extend_existing=True, autoload=True, + autoload_with=testing.db, autoload_replace=False) assert b2.c.id is not None @@ -434,7 +434,7 @@ class ReflectionTest(fixtures.TestBase, ComparesTables): meta4 = MetaData(testing.db) - u4 = Table('users', meta4, + u4 = Table('users', meta4, Column('id', sa.Integer, key='u_id', primary_key=True), autoload=True) @@ -496,7 +496,7 @@ class ReflectionTest(fixtures.TestBase, ComparesTables): @testing.provide_metadata def test_override_keys(self): - """test that columns can be overridden with a 'key', + """test that columns can be overridden with a 'key', and that ForeignKey targeting during reflection still works.""" meta = self.metadata @@ -511,7 +511,7 @@ class ReflectionTest(fixtures.TestBase, ComparesTables): ) meta.create_all() m2 = MetaData(testing.db) - a2 = Table('a', m2, + a2 = Table('a', m2, Column('x', sa.Integer, primary_key=True, key='x1'), autoload=True) b2 = Table('b', m2, autoload=True) @@ -562,7 +562,7 @@ class ReflectionTest(fixtures.TestBase, ComparesTables): meta.create_all() meta2 = MetaData(testing.db) - a2 = Table('addresses', meta2, + a2 = Table('addresses', meta2, Column('user_id',sa.Integer, sa.ForeignKey('users.id')), autoload=True) u2 = Table('users', meta2, autoload=True) @@ -701,7 +701,7 @@ class ReflectionTest(fixtures.TestBase, ComparesTables): @testing.crashes('oracle', 'FIXME: unknown, confirm not fails_on') - @testing.fails_on('+informixdb', + @testing.fails_on('+informixdb', "FIXME: should be supported via the " "DELIMITED env var but that breaks " "everything else for now") @@ -727,15 +727,15 @@ class ReflectionTest(fixtures.TestBase, ComparesTables): check_col = 'true' quoter = meta.bind.dialect.identifier_preparer.quote_identifier - table_b = Table('false', meta, - Column('create', sa.Integer, primary_key=True), + table_b = Table('false', meta, + Column('create', sa.Integer, primary_key=True), Column('true', sa.Integer,sa.ForeignKey('select.not')), sa.CheckConstraint('%s <> 1' % quoter(check_col), name='limit') ) - table_c = Table('is', meta, - Column('or', sa.Integer, nullable=False, primary_key=True), + table_c = Table('is', meta, + Column('or', sa.Integer, nullable=False, primary_key=True), Column('join', sa.Integer, nullable=False, primary_key=True), sa.PrimaryKeyConstraint('or', 'join', name='to') ) @@ -885,15 +885,15 @@ class ReflectionTest(fixtures.TestBase, ComparesTables): m2.reflect(views=False) eq_( - set(m2.tables), + set(m2.tables), set(['users', 'email_addresses', 'dingalings']) ) m2 = MetaData(testing.db) m2.reflect(views=True) eq_( - set(m2.tables), - set(['email_addresses_v', 'users_v', + set(m2.tables), + set(['email_addresses_v', 'users_v', 'users', 'dingalings', 'email_addresses']) ) finally: @@ -905,16 +905,16 @@ class CreateDropTest(fixtures.TestBase): def setup_class(cls): global metadata, users metadata = MetaData() - users = Table('users', metadata, + users = Table('users', metadata, Column('user_id', sa.Integer, sa.Sequence('user_id_seq', optional=True), - primary_key=True), + primary_key=True), Column('user_name',sa.String(40))) addresses = Table('email_addresses', metadata, Column('address_id', sa.Integer, sa.Sequence('address_id_seq', optional=True), - primary_key=True), + primary_key=True), Column('user_id', sa.Integer, sa.ForeignKey(users.c.user_id)), Column('email_address', sa.String(40))) @@ -989,8 +989,8 @@ class SchemaManipulationTest(fixtures.TestBase): meta = MetaData() users = Table('users', meta, Column('id', sa.Integer)) - addresses = Table('addresses', meta, - Column('id', sa.Integer), + addresses = Table('addresses', meta, + Column('id', sa.Integer), Column('user_id', sa.Integer)) fk = sa.ForeignKeyConstraint(['user_id'],[users.c.id]) @@ -1027,7 +1027,7 @@ class UnicodeReflectionTest(fixtures.TestBase): (u'\u6e2c\u8a66', u'col_\u6e2c\u8a66', u'ix_\u6e2c\u8a66'), ] - # as you can see, our options for this kind of thing + # as you can see, our options for this kind of thing # are really limited unless you're on PG or SQLite # forget about it on these backends @@ -1037,7 +1037,7 @@ class UnicodeReflectionTest(fixtures.TestBase): elif testing.against("mysql") and \ not testing.requires._has_mysql_fully_case_sensitive(): names = no_multibyte_period.union(no_case_sensitivity) - # mssql + pyodbc + freetds can't compare multibyte names to + # mssql + pyodbc + freetds can't compare multibyte names to # information_schema.tables.table_name elif testing.against("mssql"): names = no_multibyte_period.union(no_has_table) @@ -1208,8 +1208,8 @@ class SchemaTest(fixtures.TestBase): m2 = MetaData(schema="test_schema", bind=testing.db) m2.reflect() eq_( - set(m2.tables), - set(['test_schema.dingalings', 'test_schema.users', + set(m2.tables), + set(['test_schema.dingalings', 'test_schema.users', 'test_schema.email_addresses']) ) @@ -1286,7 +1286,7 @@ def createTables(meta, schema=None): ) dingalings = Table("dingalings", meta, Column('dingaling_id', sa.Integer, primary_key=True), - Column('address_id', sa.Integer, + Column('address_id', sa.Integer, sa.ForeignKey('%semail_addresses.address_id' % schema_prefix)), Column('data', sa.String(30)), schema=schema, @@ -1364,11 +1364,11 @@ class CaseSensitiveTest(fixtures.TablesTest): @classmethod def define_tables(cls, metadata): - Table('SomeTable', metadata, + Table('SomeTable', metadata, Column('x', Integer, primary_key=True), test_needs_fk=True ) - Table('SomeOtherTable', metadata, + Table('SomeOtherTable', metadata, Column('x', Integer, primary_key=True), Column('y', Integer, sa.ForeignKey("SomeTable.x")), test_needs_fk=True @@ -1387,8 +1387,8 @@ class CaseSensitiveTest(fixtures.TablesTest): eq_(t1.name, "SomeTable") assert t1.c.x is not None - @testing.fails_if(lambda: - testing.against(('mysql', '<', (5, 5))) and + @testing.fails_if(lambda: + testing.against(('mysql', '<', (5, 5))) and not testing.requires._has_mysql_fully_case_sensitive() ) def test_reflect_via_fk(self): diff --git a/test/engine/test_transaction.py b/test/engine/test_transaction.py index 04a3e642c..709f0d2f1 100644 --- a/test/engine/test_transaction.py +++ b/test/engine/test_transaction.py @@ -1204,7 +1204,7 @@ class IsolationLevelTest(fixtures.TestBase): eng = testing_engine(options=dict()) conn = eng.connect() eq_( - eng.dialect.get_isolation_level(conn.connection), + eng.dialect.get_isolation_level(conn.connection), self._default_isolation_level() ) @@ -1212,13 +1212,13 @@ class IsolationLevelTest(fixtures.TestBase): conn.connection, self._non_default_isolation_level() ) eq_( - eng.dialect.get_isolation_level(conn.connection), + eng.dialect.get_isolation_level(conn.connection), self._non_default_isolation_level() ) eng.dialect.reset_isolation_level(conn.connection) eq_( - eng.dialect.get_isolation_level(conn.connection), + eng.dialect.get_isolation_level(conn.connection), self._default_isolation_level() ) @@ -1243,17 +1243,17 @@ class IsolationLevelTest(fixtures.TestBase): def test_invalid_level(self): eng = testing_engine(options=dict(isolation_level='FOO')) assert_raises_message( - exc.ArgumentError, + exc.ArgumentError, "Invalid value '%s' for isolation_level. " - "Valid isolation levels for %s are %s" % - ("FOO", eng.dialect.name, + "Valid isolation levels for %s are %s" % + ("FOO", eng.dialect.name, ", ".join(eng.dialect._isolation_lookup)), eng.connect) def test_per_connection(self): from sqlalchemy.pool import QueuePool eng = testing_engine(options=dict( - poolclass=QueuePool, + poolclass=QueuePool, pool_size=2, max_overflow=0)) c1 = eng.connect() @@ -1292,7 +1292,7 @@ class IsolationLevelTest(fixtures.TestBase): r"on Connection.execution_options\(\), or " r"per-engine using the isolation_level " r"argument to create_engine\(\).", - select([1]).execution_options, + select([1]).execution_options, isolation_level=self._non_default_isolation_level() ) @@ -1305,7 +1305,7 @@ class IsolationLevelTest(fixtures.TestBase): r"To set engine-wide isolation level, " r"use the isolation_level argument to create_engine\(\).", create_engine, - testing.db.url, + testing.db.url, execution_options={'isolation_level': self._non_default_isolation_level} ) diff --git a/test/ext/test_associationproxy.py b/test/ext/test_associationproxy.py index f260e65ce..7ae467363 100644 --- a/test/ext/test_associationproxy.py +++ b/test/ext/test_associationproxy.py @@ -641,8 +641,8 @@ class ProxyFactoryTest(ListTest): ) class Parent(object): - children = association_proxy('_children', 'name', - proxy_factory=CustomProxy, + children = association_proxy('_children', 'name', + proxy_factory=CustomProxy, proxy_bulk_set=CustomProxy.extend ) @@ -1017,17 +1017,17 @@ class ComparatorTest(fixtures.MappedTest, AssertsCompiledSQL): @classmethod def define_tables(cls, metadata): - Table('userkeywords', metadata, + Table('userkeywords', metadata, Column('keyword_id', Integer,ForeignKey('keywords.id'), primary_key=True), Column('user_id', Integer, ForeignKey('users.id')) ) - Table('users', metadata, + Table('users', metadata, Column('id', Integer, primary_key=True, test_needs_autoincrement=True), Column('name', String(64)), Column('singular_id', Integer, ForeignKey('singular.id')) ) - Table('keywords', metadata, + Table('keywords', metadata, Column('id', Integer, primary_key=True, test_needs_autoincrement=True), Column('keyword', String(64)), @@ -1090,7 +1090,7 @@ class ComparatorTest(fixtures.MappedTest, AssertsCompiledSQL): }) mapper(UserKeyword, userkeywords, properties={ - 'user' : relationship(User, backref='user_keywords'), + 'user' : relationship(User, backref='user_keywords'), 'keyword' : relationship(Keyword) }) mapper(Singular, singular, properties={ @@ -1288,7 +1288,7 @@ class ComparatorTest(fixtures.MappedTest, AssertsCompiledSQL): User = self.classes.User self.assert_compile( self.session.query(User).join( - User.keywords.local_attr, + User.keywords.local_attr, User.keywords.remote_attr), "SELECT users.id AS users_id, users.name AS users_name, " "users.singular_id AS users_singular_id " @@ -1321,7 +1321,7 @@ class DictOfTupleUpdateTest(fixtures.TestBase): m = MetaData() a = Table('a', m, Column('id', Integer, primary_key=True)) - b = Table('b', m, Column('id', Integer, primary_key=True), + b = Table('b', m, Column('id', Integer, primary_key=True), Column('aid', Integer, ForeignKey('a.id'))) mapper(A, a, properties={ 'orig':relationship(B, collection_class=attribute_mapped_collection('key')) diff --git a/test/ext/test_compiler.py b/test/ext/test_compiler.py index 4e8a40ff3..ee64548f5 100644 --- a/test/ext/test_compiler.py +++ b/test/ext/test_compiler.py @@ -123,7 +123,7 @@ class UserDefinedTest(fixtures.TestBase, AssertsCompiledSQL): ) def test_annotations(self): - """test that annotated clause constructs use the + """test that annotated clause constructs use the decorated class' compiler. """ @@ -356,7 +356,7 @@ class DefaultOnExistingTest(fixtures.TestBase, AssertsCompiledSQL): return "BIND(%s)" % compiler.visit_bindparam(element, **kw) self.assert_compile( - t.select().where(t.c.c == 5), + t.select().where(t.c.c == 5), "SELECT t.a, t.b, t.c FROM t WHERE t.c = BIND(:c_1)", use_default_dialect=True ) @@ -373,7 +373,7 @@ class DefaultOnExistingTest(fixtures.TestBase, AssertsCompiledSQL): return "BIND(%s)" % compiler.visit_bindparam(element, **kw) self.assert_compile( - t.insert(), + t.insert(), "INSERT INTO t (a, b) VALUES (BIND(:a), BIND(:b))", {'a':1, 'b':2}, use_default_dialect=True diff --git a/test/ext/test_declarative.py b/test/ext/test_declarative.py index 36cd598ab..e9494b295 100644 --- a/test/ext/test_declarative.py +++ b/test/ext/test_declarative.py @@ -279,8 +279,8 @@ class DeclarativeTest(DeclarativeTestBase): id = Column(Integer, primary_key=True, test_needs_autoincrement=True) email = Column(String(50)) - user_id = Column(Integer) - user = relationship("User", + user_id = Column(Integer) + user = relationship("User", primaryjoin="remote(User.id)==foreign(Address.user_id)" ) @@ -371,7 +371,7 @@ class DeclarativeTest(DeclarativeTestBase): name = Column(String(50)) props = relationship('Prop', secondary='fooschema.user_to_prop', primaryjoin='User.id==fooschema.user_to_prop.c.user_id', - secondaryjoin='fooschema.user_to_prop.c.prop_id==Prop.id', + secondaryjoin='fooschema.user_to_prop.c.prop_id==Prop.id', backref='users') class Prop(Base): @@ -383,7 +383,7 @@ class DeclarativeTest(DeclarativeTestBase): name = Column(String(50)) user_to_prop = Table('user_to_prop', Base.metadata, - Column('user_id', Integer, ForeignKey('fooschema.users.id')), + Column('user_id', Integer, ForeignKey('fooschema.users.id')), Column('prop_id',Integer, ForeignKey('fooschema.props.id')), schema='fooschema') configure_mappers() @@ -503,7 +503,7 @@ class DeclarativeTest(DeclarativeTestBase): except exc.InvalidRequestError: assert sa.util.compat.py32 - # the exception is preserved. Remains the + # the exception is preserved. Remains the # same through repeated calls. for i in range(3): assert_raises_message(sa.exc.InvalidRequestError, @@ -1006,9 +1006,9 @@ class DeclarativeTest(DeclarativeTestBase): class User(Base, fixtures.ComparableEntity): __tablename__ = 'user' - id = Column(Integer, primary_key=True, + id = Column(Integer, primary_key=True, test_needs_autoincrement=True) - address = composite(AddressComposite, + address = composite(AddressComposite, Column('street', String(50)), Column('state', String(2)), ) @@ -1016,13 +1016,13 @@ class DeclarativeTest(DeclarativeTestBase): Base.metadata.create_all() sess = Session() sess.add(User( - address=AddressComposite('123 anywhere street', + address=AddressComposite('123 anywhere street', 'MD') )) sess.commit() eq_( - sess.query(User).all(), - [User(address=AddressComposite('123 anywhere street', + sess.query(User).all(), + [User(address=AddressComposite('123 anywhere street', 'MD'))] ) @@ -1036,23 +1036,23 @@ class DeclarativeTest(DeclarativeTestBase): class User(Base, fixtures.ComparableEntity): __tablename__ = 'user' - id = Column(Integer, primary_key=True, + id = Column(Integer, primary_key=True, test_needs_autoincrement=True) street = Column(String(50)) state = Column(String(2)) - address = composite(AddressComposite, + address = composite(AddressComposite, street, state) Base.metadata.create_all() sess = Session() sess.add(User( - address=AddressComposite('123 anywhere street', + address=AddressComposite('123 anywhere street', 'MD') )) sess.commit() eq_( - sess.query(User).all(), - [User(address=AddressComposite('123 anywhere street', + sess.query(User).all(), + [User(address=AddressComposite('123 anywhere street', 'MD'))] ) diff --git a/test/ext/test_declarative_mixin.py b/test/ext/test_declarative_mixin.py index db176aa6d..0876ebe63 100644 --- a/test/ext/test_declarative_mixin.py +++ b/test/ext/test_declarative_mixin.py @@ -540,7 +540,7 @@ class DeclarativeMixinTest(DeclarativeTestBase): pass eq_( - MyModel.__mapper__.polymorphic_on.name, + MyModel.__mapper__.polymorphic_on.name, 'type_' ) assert MyModel.__mapper__.polymorphic_on.table is not None @@ -804,8 +804,8 @@ class DeclarativeMixinTest(DeclarativeTestBase): class Model(Base, ColumnMixin): - __table__ = Table('foo', Base.metadata, - Column('data',Integer), + __table__ = Table('foo', Base.metadata, + Column('data',Integer), Column('id', Integer,primary_key=True)) foo = relationship("Dest") @@ -826,8 +826,8 @@ class DeclarativeMixinTest(DeclarativeTestBase): class Model(Base, ColumnMixin): - __table__ = Table('foo', Base.metadata, - Column('data',Integer), + __table__ = Table('foo', Base.metadata, + Column('data',Integer), Column('tada', Integer), Column('id', Integer,primary_key=True)) foo = relationship("Dest") diff --git a/test/ext/test_declarative_reflection.py b/test/ext/test_declarative_reflection.py index a99c05af9..6efc6e64e 100644 --- a/test/ext/test_declarative_reflection.py +++ b/test/ext/test_declarative_reflection.py @@ -23,7 +23,7 @@ class DeclarativeReflectionTest(DeclarativeReflectionBase): @classmethod def define_tables(cls, metadata): - Table('users', metadata, + Table('users', metadata, Column('id', Integer, primary_key=True, test_needs_autoincrement=True), Column('name', String(50)), test_needs_fk=True) @@ -162,7 +162,7 @@ class DeferredReflectPKFKTest(DeferredReflectBase): Column('id', Integer, primary_key=True, test_needs_autoincrement=True), ) - Table("b", metadata, + Table("b", metadata, Column('id', Integer, ForeignKey('a.id'), primary_key=True), @@ -170,12 +170,12 @@ class DeferredReflectPKFKTest(DeferredReflectBase): ) def test_pk_fk(self): - class B(decl.DeferredReflection, fixtures.ComparableEntity, + class B(decl.DeferredReflection, fixtures.ComparableEntity, Base): __tablename__ = 'b' a = relationship("A") - class A(decl.DeferredReflection, fixtures.ComparableEntity, + class A(decl.DeferredReflection, fixtures.ComparableEntity, Base): __tablename__ = 'a' @@ -185,7 +185,7 @@ class DeferredReflectionTest(DeferredReflectBase): @classmethod def define_tables(cls, metadata): - Table('users', metadata, + Table('users', metadata, Column('id', Integer, primary_key=True, test_needs_autoincrement=True), Column('name', String(50)), test_needs_fk=True) @@ -217,12 +217,12 @@ class DeferredReflectionTest(DeferredReflectBase): eq_(a1.user, User(name='u1')) def test_basic_deferred(self): - class User(decl.DeferredReflection, fixtures.ComparableEntity, + class User(decl.DeferredReflection, fixtures.ComparableEntity, Base): __tablename__ = 'users' addresses = relationship("Address", backref="user") - class Address(decl.DeferredReflection, fixtures.ComparableEntity, + class Address(decl.DeferredReflection, fixtures.ComparableEntity, Base): __tablename__ = 'addresses' @@ -250,12 +250,12 @@ class DeferredReflectionTest(DeferredReflectBase): self._roundtrip() def test_redefine_fk_double(self): - class User(decl.DeferredReflection, fixtures.ComparableEntity, + class User(decl.DeferredReflection, fixtures.ComparableEntity, Base): __tablename__ = 'users' addresses = relationship("Address", backref="user") - class Address(decl.DeferredReflection, fixtures.ComparableEntity, + class Address(decl.DeferredReflection, fixtures.ComparableEntity, Base): __tablename__ = 'addresses' user_id = Column(Integer, ForeignKey('users.id')) @@ -266,7 +266,7 @@ class DeferredReflectionTest(DeferredReflectBase): def test_mapper_args_deferred(self): """test that __mapper_args__ is not called until *after* table reflection""" - class User(decl.DeferredReflection, fixtures.ComparableEntity, + class User(decl.DeferredReflection, fixtures.ComparableEntity, Base): __tablename__ = 'users' @@ -301,7 +301,7 @@ class DeferredInhReflectBase(DeferredReflectBase): Bar = Base._decl_class_registry['Bar'] s = Session(testing.db) - + s.add_all([ Bar(data='d1', bar_data='b1'), Bar(data='d2', bar_data='b2'), @@ -325,7 +325,7 @@ class DeferredSingleInhReflectionTest(DeferredInhReflectBase): @classmethod def define_tables(cls, metadata): Table("foo", metadata, - Column('id', Integer, primary_key=True, + Column('id', Integer, primary_key=True, test_needs_autoincrement=True), Column('type', String(32)), Column('data', String(30)), @@ -333,10 +333,10 @@ class DeferredSingleInhReflectionTest(DeferredInhReflectBase): ) def test_basic(self): - class Foo(decl.DeferredReflection, fixtures.ComparableEntity, + class Foo(decl.DeferredReflection, fixtures.ComparableEntity, Base): __tablename__ = 'foo' - __mapper_args__ = {"polymorphic_on":"type", + __mapper_args__ = {"polymorphic_on":"type", "polymorphic_identity":"foo"} class Bar(Foo): @@ -346,10 +346,10 @@ class DeferredSingleInhReflectionTest(DeferredInhReflectBase): self._roundtrip() def test_add_subclass_column(self): - class Foo(decl.DeferredReflection, fixtures.ComparableEntity, + class Foo(decl.DeferredReflection, fixtures.ComparableEntity, Base): __tablename__ = 'foo' - __mapper_args__ = {"polymorphic_on":"type", + __mapper_args__ = {"polymorphic_on":"type", "polymorphic_identity":"foo"} class Bar(Foo): @@ -360,10 +360,10 @@ class DeferredSingleInhReflectionTest(DeferredInhReflectBase): self._roundtrip() def test_add_pk_column(self): - class Foo(decl.DeferredReflection, fixtures.ComparableEntity, + class Foo(decl.DeferredReflection, fixtures.ComparableEntity, Base): __tablename__ = 'foo' - __mapper_args__ = {"polymorphic_on":"type", + __mapper_args__ = {"polymorphic_on":"type", "polymorphic_identity":"foo"} id = Column(Integer, primary_key=True) @@ -377,7 +377,7 @@ class DeferredJoinedInhReflectionTest(DeferredInhReflectBase): @classmethod def define_tables(cls, metadata): Table("foo", metadata, - Column('id', Integer, primary_key=True, + Column('id', Integer, primary_key=True, test_needs_autoincrement=True), Column('type', String(32)), Column('data', String(30)), @@ -390,10 +390,10 @@ class DeferredJoinedInhReflectionTest(DeferredInhReflectBase): ) def test_basic(self): - class Foo(decl.DeferredReflection, fixtures.ComparableEntity, + class Foo(decl.DeferredReflection, fixtures.ComparableEntity, Base): __tablename__ = 'foo' - __mapper_args__ = {"polymorphic_on":"type", + __mapper_args__ = {"polymorphic_on":"type", "polymorphic_identity":"foo"} class Bar(Foo): @@ -404,10 +404,10 @@ class DeferredJoinedInhReflectionTest(DeferredInhReflectBase): self._roundtrip() def test_add_subclass_column(self): - class Foo(decl.DeferredReflection, fixtures.ComparableEntity, + class Foo(decl.DeferredReflection, fixtures.ComparableEntity, Base): __tablename__ = 'foo' - __mapper_args__ = {"polymorphic_on":"type", + __mapper_args__ = {"polymorphic_on":"type", "polymorphic_identity":"foo"} class Bar(Foo): @@ -419,10 +419,10 @@ class DeferredJoinedInhReflectionTest(DeferredInhReflectBase): self._roundtrip() def test_add_pk_column(self): - class Foo(decl.DeferredReflection, fixtures.ComparableEntity, + class Foo(decl.DeferredReflection, fixtures.ComparableEntity, Base): __tablename__ = 'foo' - __mapper_args__ = {"polymorphic_on":"type", + __mapper_args__ = {"polymorphic_on":"type", "polymorphic_identity":"foo"} id = Column(Integer, primary_key=True) @@ -434,10 +434,10 @@ class DeferredJoinedInhReflectionTest(DeferredInhReflectBase): self._roundtrip() def test_add_fk_pk_column(self): - class Foo(decl.DeferredReflection, fixtures.ComparableEntity, + class Foo(decl.DeferredReflection, fixtures.ComparableEntity, Base): __tablename__ = 'foo' - __mapper_args__ = {"polymorphic_on":"type", + __mapper_args__ = {"polymorphic_on":"type", "polymorphic_identity":"foo"} class Bar(Foo): diff --git a/test/lib/__init__.py b/test/lib/__init__.py index 68876c447..b36db71fc 100644 --- a/test/lib/__init__.py +++ b/test/lib/__init__.py @@ -1,6 +1,6 @@ """Testing environment and utilities. -This package contains base classes and routines used by +This package contains base classes and routines used by the unit tests. Tests are based on Nose and bootstrapped by noseplugin.NoseSQLAlchemy. diff --git a/test/lib/fixtures.py b/test/lib/fixtures.py index 41a72c9a4..451eeb43b 100644 --- a/test/lib/fixtures.py +++ b/test/lib/fixtures.py @@ -268,7 +268,7 @@ class MappedTest(_ORMTest, TablesTest, testing.AssertsExecutionResults): """Run a setup method, framing the operation with a Base class that will catch new subclasses to be established within the "classes" registry. - + """ cls_registry = cls.classes class FindFixture(type): @@ -289,7 +289,7 @@ class MappedTest(_ORMTest, TablesTest, testing.AssertsExecutionResults): def _teardown_each_mappers(self): # some tests create mappers in the test bodies - # and will define setup_mappers as None - + # and will define setup_mappers as None - # clear mappers in any case if self.run_setup_mappers != 'once': sa.orm.clear_mappers() @@ -328,7 +328,7 @@ class DeclarativeMappedTest(MappedTest): cls, classname, bases, dict_) class DeclarativeBasic(object): __table_cls__ = schema.Table - _DeclBase = declarative_base(metadata=cls.declarative_meta, + _DeclBase = declarative_base(metadata=cls.declarative_meta, metaclass=FindFixtureDeclarative, cls=DeclarativeBasic) cls.DeclarativeBasic = _DeclBase diff --git a/test/lib/profiling.py b/test/lib/profiling.py index bac9e549f..f47145718 100644 --- a/test/lib/profiling.py +++ b/test/lib/profiling.py @@ -69,12 +69,12 @@ def profiled(target=None, **target_opts): else: stats.print_stats() - print_callers = target_opts.get('print_callers', + print_callers = target_opts.get('print_callers', profile_config['print_callers']) if print_callers: stats.print_callers() - print_callees = target_opts.get('print_callees', + print_callees = target_opts.get('print_callees', profile_config['print_callees']) if print_callees: stats.print_callees() diff --git a/test/lib/requires.py b/test/lib/requires.py index 88049d7fb..31b835b28 100644 --- a/test/lib/requires.py +++ b/test/lib/requires.py @@ -77,9 +77,9 @@ def identity(fn): def reflectable_autoincrement(fn): """Target database must support tables that can automatically generate PKs assuming they were reflected. - + this is essentially all the DBs in "identity" plus Postgresql, which - has SERIAL support. FB and Oracle (and sybase?) require the Sequence to + has SERIAL support. FB and Oracle (and sybase?) require the Sequence to be explicitly added, including if the table was reflected. """ return _chain_decorators_on( @@ -151,7 +151,7 @@ def update_from(fn): """Target must support UPDATE..FROM syntax""" return _chain_decorators_on( fn, - only_on(('postgresql', 'mssql', 'mysql'), + only_on(('postgresql', 'mssql', 'mysql'), "Backend does not support UPDATE..FROM") ) @@ -388,7 +388,7 @@ def python25(fn): def cpython(fn): return _chain_decorators_on( fn, - skip_if(lambda: util.jython or util.pypy, + skip_if(lambda: util.jython or util.pypy, "cPython interpreter needed" ) ) @@ -424,11 +424,11 @@ def sqlite(fn): def ad_hoc_engines(fn): """Test environment must allow ad-hoc engine/connection creation. - + DBs that scale poorly for many connections, even when closed, i.e. Oracle, may use the "--low-connections" option which flags this requirement as not present. - + """ return _chain_decorators_on( fn, @@ -456,6 +456,6 @@ def selectone(fn): """target driver must support the literal statement 'select 1'""" return _chain_decorators_on( fn, - skip_if(lambda: testing.against('oracle'), + skip_if(lambda: testing.against('oracle'), "non-standard SELECT scalar syntax") ) diff --git a/test/lib/testing.py b/test/lib/testing.py index d3bccb53c..02d592235 100644 --- a/test/lib/testing.py +++ b/test/lib/testing.py @@ -95,7 +95,7 @@ def db_spec(*dbs): def fails_on(dbs, reason): - """Mark a test as expected to fail on the specified database + """Mark a test as expected to fail on the specified database implementation. Unlike ``crashes``, tests marked as ``fails_on`` will be run @@ -425,7 +425,7 @@ def resetwarnings(): util.warn = util.langhelpers.warn = testing_warn warnings.filterwarnings('ignore', - category=sa_exc.SAPendingDeprecationWarning) + category=sa_exc.SAPendingDeprecationWarning) warnings.filterwarnings('error', category=sa_exc.SADeprecationWarning) warnings.filterwarnings('error', category=sa_exc.SAWarning) @@ -479,9 +479,9 @@ def _chain_decorators_on(fn, *decorators): def run_as_contextmanager(ctx, fn, *arg, **kw): """Run the given function under the given contextmanager, - simulating the behavior of 'with' to support older + simulating the behavior of 'with' to support older Python versions. - + """ obj = ctx.__enter__() @@ -576,8 +576,8 @@ class adict(dict): class AssertsCompiledSQL(object): - def assert_compile(self, clause, result, params=None, - checkparams=None, dialect=None, + def assert_compile(self, clause, result, params=None, + checkparams=None, dialect=None, checkpositional=None, use_default_dialect=False, allow_dialect_select=False): diff --git a/test/orm/_fixtures.py b/test/orm/_fixtures.py index 7431a3a83..d0d3a9ec4 100644 --- a/test/orm/_fixtures.py +++ b/test/orm/_fixtures.py @@ -82,7 +82,7 @@ class FixtureTest(fixtures.MappedTest): mapper(Keyword, keywords) mapper(Node, nodes, properties={ - 'children':relationship(Node, + 'children':relationship(Node, backref=backref('parent', remote_side=[nodes.c.id]) ) }) diff --git a/test/orm/inheritance/test_abc_inheritance.py b/test/orm/inheritance/test_abc_inheritance.py index e1304e26e..19d4f923b 100644 --- a/test/orm/inheritance/test_abc_inheritance.py +++ b/test/orm/inheritance/test_abc_inheritance.py @@ -111,10 +111,10 @@ def produce_test(parent, child, direction): parent_class = parent_mapper.class_ child_class = child_mapper.class_ - parent_mapper.add_property("collection", - relationship(child_mapper, - primaryjoin=relationshipjoin, - foreign_keys=foreign_keys, + parent_mapper.add_property("collection", + relationship(child_mapper, + primaryjoin=relationshipjoin, + foreign_keys=foreign_keys, remote_side=remote_side, uselist=True)) sess = create_session() diff --git a/test/orm/inheritance/test_assorted_poly.py b/test/orm/inheritance/test_assorted_poly.py index 985d892d8..6ff989e73 100644 --- a/test/orm/inheritance/test_assorted_poly.py +++ b/test/orm/inheritance/test_assorted_poly.py @@ -29,17 +29,17 @@ class RelationshipTest1(fixtures.MappedTest): global people, managers people = Table('people', metadata, - Column('person_id', Integer, Sequence('person_id_seq', - optional=True), + Column('person_id', Integer, Sequence('person_id_seq', + optional=True), primary_key=True), - Column('manager_id', Integer, - ForeignKey('managers.person_id', + Column('manager_id', Integer, + ForeignKey('managers.person_id', use_alter=True, name="mpid_fq")), Column('name', String(50)), Column('type', String(30))) managers = Table('managers', metadata, - Column('person_id', Integer, ForeignKey('people.person_id'), + Column('person_id', Integer, ForeignKey('people.person_id'), primary_key=True), Column('status', String(30)), Column('manager_name', String(50)) @@ -64,7 +64,7 @@ class RelationshipTest1(fixtures.MappedTest): mapper(Manager, managers, inherits=Person, inherit_condition=people.c.person_id==managers.c.person_id) - eq_(class_mapper(Person).get_property('manager').synchronize_pairs, + eq_(class_mapper(Person).get_property('manager').synchronize_pairs, [(managers.c.person_id,people.c.manager_id)]) session = create_session() @@ -86,9 +86,9 @@ class RelationshipTest1(fixtures.MappedTest): pass mapper(Person, people) - mapper(Manager, managers, inherits=Person, + mapper(Manager, managers, inherits=Person, inherit_condition=people.c.person_id== - managers.c.person_id, + managers.c.person_id, properties={ 'employee':relationship(Person, primaryjoin=( people.c.manager_id == @@ -115,7 +115,7 @@ class RelationshipTest2(fixtures.MappedTest): def define_tables(cls, metadata): global people, managers, data people = Table('people', metadata, - Column('person_id', Integer, primary_key=True, + Column('person_id', Integer, primary_key=True, test_needs_autoincrement=True), Column('name', String(50)), Column('type', String(30))) @@ -128,7 +128,7 @@ class RelationshipTest2(fixtures.MappedTest): ) data = Table('data', metadata, - Column('person_id', Integer, ForeignKey('managers.person_id'), + Column('person_id', Integer, ForeignKey('managers.person_id'), primary_key=True), Column('data', String(30)) ) @@ -155,14 +155,14 @@ class RelationshipTest2(fixtures.MappedTest): if jointype == "join1": poly_union = polymorphic_union({ 'person':people.select(people.c.type=='person'), - 'manager':join(people, managers, + 'manager':join(people, managers, people.c.person_id==managers.c.person_id) }, None) polymorphic_on=poly_union.c.type elif jointype == "join2": poly_union = polymorphic_union({ 'person':people.select(people.c.type=='person'), - 'manager':managers.join(people, + 'manager':managers.join(people, people.c.person_id==managers.c.person_id) }, None) polymorphic_on=poly_union.c.type @@ -176,35 +176,35 @@ class RelationshipTest2(fixtures.MappedTest): self.data = data mapper(Data, data) - mapper(Person, people, - with_polymorphic=('*', poly_union), - polymorphic_identity='person', + mapper(Person, people, + with_polymorphic=('*', poly_union), + polymorphic_identity='person', polymorphic_on=polymorphic_on) if usedata: - mapper(Manager, managers, - inherits=Person, + mapper(Manager, managers, + inherits=Person, inherit_condition=people.c.person_id== - managers.c.person_id, + managers.c.person_id, polymorphic_identity='manager', properties={ 'colleague':relationship( - Person, + Person, primaryjoin=managers.c.manager_id== - people.c.person_id, + people.c.person_id, lazy='select', uselist=False), 'data':relationship(Data, uselist=False) } ) else: - mapper(Manager, managers, inherits=Person, + mapper(Manager, managers, inherits=Person, inherit_condition=people.c.person_id== - managers.c.person_id, + managers.c.person_id, polymorphic_identity='manager', properties={ - 'colleague':relationship(Person, + 'colleague':relationship(Person, primaryjoin=managers.c.manager_id== - people.c.person_id, + people.c.person_id, lazy='select', uselist=False) } ) @@ -231,20 +231,20 @@ class RelationshipTest3(fixtures.MappedTest): def define_tables(cls, metadata): global people, managers, data people = Table('people', metadata, - Column('person_id', Integer, primary_key=True, + Column('person_id', Integer, primary_key=True, test_needs_autoincrement=True), Column('colleague_id', Integer, ForeignKey('people.person_id')), Column('name', String(50)), Column('type', String(30))) managers = Table('managers', metadata, - Column('person_id', Integer, ForeignKey('people.person_id'), + Column('person_id', Integer, ForeignKey('people.person_id'), primary_key=True), Column('status', String(30)), ) data = Table('data', metadata, - Column('person_id', Integer, ForeignKey('people.person_id'), + Column('person_id', Integer, ForeignKey('people.person_id'), primary_key=True), Column('data', String(30)) ) @@ -263,13 +263,13 @@ def _generate_test(jointype="join1", usedata=False): if jointype == "join1": poly_union = polymorphic_union({ - 'manager':managers.join(people, + 'manager':managers.join(people, people.c.person_id==managers.c.person_id), 'person':people.select(people.c.type=='person') }, None) elif jointype =="join2": poly_union = polymorphic_union({ - 'manager':join(people, managers, + 'manager':join(people, managers, people.c.person_id==managers.c.person_id), 'person':people.select(people.c.type=='person') }, None) @@ -282,34 +282,34 @@ def _generate_test(jointype="join1", usedata=False): mapper(Data, data) if usedata: - mapper(Person, people, - with_polymorphic=('*', poly_union), - polymorphic_identity='person', + mapper(Person, people, + with_polymorphic=('*', poly_union), + polymorphic_identity='person', polymorphic_on=people.c.type, properties={ - 'colleagues':relationship(Person, + 'colleagues':relationship(Person, primaryjoin=people.c.colleague_id== - people.c.person_id, - remote_side=people.c.colleague_id, + people.c.person_id, + remote_side=people.c.colleague_id, uselist=True), 'data':relationship(Data, uselist=False) } ) else: - mapper(Person, people, - with_polymorphic=('*', poly_union), - polymorphic_identity='person', + mapper(Person, people, + with_polymorphic=('*', poly_union), + polymorphic_identity='person', polymorphic_on=people.c.type, properties={ - 'colleagues':relationship(Person, + 'colleagues':relationship(Person, primaryjoin=people.c.colleague_id==people.c.person_id, remote_side=people.c.colleague_id, uselist=True) } ) - mapper(Manager, managers, inherits=Person, + mapper(Manager, managers, inherits=Person, inherit_condition=people.c.person_id== - managers.c.person_id, + managers.c.person_id, polymorphic_identity='manager') sess = create_session() @@ -355,22 +355,22 @@ class RelationshipTest4(fixtures.MappedTest): def define_tables(cls, metadata): global people, engineers, managers, cars people = Table('people', metadata, - Column('person_id', Integer, primary_key=True, + Column('person_id', Integer, primary_key=True, test_needs_autoincrement=True), Column('name', String(50))) engineers = Table('engineers', metadata, - Column('person_id', Integer, ForeignKey('people.person_id'), + Column('person_id', Integer, ForeignKey('people.person_id'), primary_key=True), Column('status', String(30))) managers = Table('managers', metadata, - Column('person_id', Integer, ForeignKey('people.person_id'), + Column('person_id', Integer, ForeignKey('people.person_id'), primary_key=True), Column('longer_status', String(70))) cars = Table('cars', metadata, - Column('car_id', Integer, primary_key=True, + Column('car_id', Integer, primary_key=True, test_needs_autoincrement=True), Column('owner', Integer, ForeignKey('people.person_id'))) @@ -411,17 +411,17 @@ class RelationshipTest4(fixtures.MappedTest): 'manager':people.join(managers), }, "type", 'employee_join') - person_mapper = mapper(Person, people, - with_polymorphic=('*', employee_join), - polymorphic_on=employee_join.c.type, + person_mapper = mapper(Person, people, + with_polymorphic=('*', employee_join), + polymorphic_on=employee_join.c.type, polymorphic_identity='person') - engineer_mapper = mapper(Engineer, engineers, - inherits=person_mapper, + engineer_mapper = mapper(Engineer, engineers, + inherits=person_mapper, polymorphic_identity='engineer') - manager_mapper = mapper(Manager, managers, - inherits=person_mapper, + manager_mapper = mapper(Manager, managers, + inherits=person_mapper, polymorphic_identity='manager') - car_mapper = mapper(Car, cars, + car_mapper = mapper(Car, cars, properties= {'employee': relationship(person_mapper)}) @@ -485,23 +485,23 @@ class RelationshipTest5(fixtures.MappedTest): def define_tables(cls, metadata): global people, engineers, managers, cars people = Table('people', metadata, - Column('person_id', Integer, primary_key=True, + Column('person_id', Integer, primary_key=True, test_needs_autoincrement=True), Column('name', String(50)), Column('type', String(50))) engineers = Table('engineers', metadata, - Column('person_id', Integer, ForeignKey('people.person_id'), + Column('person_id', Integer, ForeignKey('people.person_id'), primary_key=True), Column('status', String(30))) managers = Table('managers', metadata, - Column('person_id', Integer, ForeignKey('people.person_id'), + Column('person_id', Integer, ForeignKey('people.person_id'), primary_key=True), Column('longer_status', String(70))) cars = Table('cars', metadata, - Column('car_id', Integer, primary_key=True, + Column('car_id', Integer, primary_key=True, test_needs_autoincrement=True), Column('owner', Integer, ForeignKey('people.person_id'))) @@ -530,14 +530,14 @@ class RelationshipTest5(fixtures.MappedTest): def __repr__(self): return "Car number %d" % self.car_id - person_mapper = mapper(Person, people, - polymorphic_on=people.c.type, + person_mapper = mapper(Person, people, + polymorphic_on=people.c.type, polymorphic_identity='person') - engineer_mapper = mapper(Engineer, engineers, - inherits=person_mapper, + engineer_mapper = mapper(Engineer, engineers, + inherits=person_mapper, polymorphic_identity='engineer') - manager_mapper = mapper(Manager, managers, - inherits=person_mapper, + manager_mapper = mapper(Manager, managers, + inherits=person_mapper, polymorphic_identity='manager') car_mapper = mapper(Car, cars, properties= { 'manager':relationship( @@ -564,15 +564,15 @@ class RelationshipTest6(fixtures.MappedTest): def define_tables(cls, metadata): global people, managers, data people = Table('people', metadata, - Column('person_id', Integer, primary_key=True, + Column('person_id', Integer, primary_key=True, test_needs_autoincrement=True), Column('name', String(50)), ) managers = Table('managers', metadata, - Column('person_id', Integer, ForeignKey('people.person_id'), + Column('person_id', Integer, ForeignKey('people.person_id'), primary_key=True), - Column('colleague_id', Integer, + Column('colleague_id', Integer, ForeignKey('managers.person_id')), Column('status', String(30)), ) @@ -585,13 +585,13 @@ class RelationshipTest6(fixtures.MappedTest): mapper(Person, people) - mapper(Manager, managers, inherits=Person, + mapper(Manager, managers, inherits=Person, inherit_condition=people.c.person_id==\ managers.c.person_id, properties={ - 'colleague':relationship(Manager, + 'colleague':relationship(Manager, primaryjoin=managers.c.colleague_id==\ - managers.c.person_id, + managers.c.person_id, lazy='select', uselist=False) } ) @@ -613,7 +613,7 @@ class RelationshipTest7(fixtures.MappedTest): def define_tables(cls, metadata): global people, engineers, managers, cars, offroad_cars cars = Table('cars', metadata, - Column('car_id', Integer, primary_key=True, + Column('car_id', Integer, primary_key=True, test_needs_autoincrement=True), Column('name', String(30))) @@ -622,20 +622,20 @@ class RelationshipTest7(fixtures.MappedTest): nullable=False,primary_key=True)) people = Table('people', metadata, - Column('person_id', Integer, primary_key=True, + Column('person_id', Integer, primary_key=True, test_needs_autoincrement=True), - Column('car_id', Integer, ForeignKey('cars.car_id'), + Column('car_id', Integer, ForeignKey('cars.car_id'), nullable=False), Column('name', String(50))) engineers = Table('engineers', metadata, - Column('person_id', Integer, ForeignKey('people.person_id'), + Column('person_id', Integer, ForeignKey('people.person_id'), primary_key=True), Column('field', String(30))) managers = Table('managers', metadata, - Column('person_id', Integer, ForeignKey('people.person_id'), + Column('person_id', Integer, ForeignKey('people.person_id'), primary_key=True), Column('category', String(70))) @@ -659,12 +659,12 @@ class RelationshipTest7(fixtures.MappedTest): class Engineer(Person): def __repr__(self): - return "Engineer %s, field %s" % (self.name, + return "Engineer %s, field %s" % (self.name, self.field) class Manager(Person): def __repr__(self): - return "Manager %s, category %s" % (self.name, + return "Manager %s, category %s" % (self.name, self.category) class Car(PersistentObject): @@ -686,7 +686,7 @@ class RelationshipTest7(fixtures.MappedTest): car_join = polymorphic_union( { 'car' : cars.outerjoin(offroad_cars).\ - select(offroad_cars.c.car_id == None, + select(offroad_cars.c.car_id == None, fold_equivalents=True), 'offroad' : cars.join(offroad_cars) }, "type", 'car_join') @@ -695,20 +695,20 @@ class RelationshipTest7(fixtures.MappedTest): with_polymorphic=('*', car_join) ,polymorphic_on=car_join.c.type, polymorphic_identity='car', ) - offroad_car_mapper = mapper(Offraod_Car, offroad_cars, + offroad_car_mapper = mapper(Offraod_Car, offroad_cars, inherits=car_mapper, polymorphic_identity='offroad') person_mapper = mapper(Person, people, - with_polymorphic=('*', employee_join), + with_polymorphic=('*', employee_join), polymorphic_on=employee_join.c.type, polymorphic_identity='person', properties={ 'car':relationship(car_mapper) }) - engineer_mapper = mapper(Engineer, engineers, - inherits=person_mapper, + engineer_mapper = mapper(Engineer, engineers, + inherits=person_mapper, polymorphic_identity='engineer') - manager_mapper = mapper(Manager, managers, - inherits=person_mapper, + manager_mapper = mapper(Manager, managers, + inherits=person_mapper, polymorphic_identity='manager') session = create_session() @@ -735,13 +735,13 @@ class RelationshipTest8(fixtures.MappedTest): def define_tables(cls, metadata): global taggable, users taggable = Table('taggable', metadata, - Column('id', Integer, primary_key=True, + Column('id', Integer, primary_key=True, test_needs_autoincrement=True), Column('type', String(30)), Column('owner_id', Integer, ForeignKey('taggable.id')), ) users = Table ('users', metadata, - Column('id', Integer, ForeignKey('taggable.id'), + Column('id', Integer, ForeignKey('taggable.id'), primary_key=True), Column('data', String(50)), ) @@ -753,9 +753,9 @@ class RelationshipTest8(fixtures.MappedTest): class User(Taggable): pass - mapper( Taggable, taggable, - polymorphic_on=taggable.c.type, - polymorphic_identity='taggable', + mapper( Taggable, taggable, + polymorphic_on=taggable.c.type, + polymorphic_identity='taggable', properties = { 'owner' : relationship (User, primaryjoin=taggable.c.owner_id ==taggable.c.id, @@ -764,7 +764,7 @@ class RelationshipTest8(fixtures.MappedTest): }) - mapper(User, users, inherits=Taggable, + mapper(User, users, inherits=Taggable, polymorphic_identity='user', inherit_condition=users.c.id == taggable.c.id, ) @@ -796,33 +796,33 @@ class GenerativeTest(fixtures.TestBase, AssertsExecutionResults): metadata = MetaData(testing.db) # table definitions status = Table('status', metadata, - Column('status_id', Integer, primary_key=True, + Column('status_id', Integer, primary_key=True, test_needs_autoincrement=True), Column('name', String(20))) people = Table('people', metadata, - Column('person_id', Integer, primary_key=True, + Column('person_id', Integer, primary_key=True, test_needs_autoincrement=True), - Column('status_id', Integer, ForeignKey('status.status_id'), + Column('status_id', Integer, ForeignKey('status.status_id'), nullable=False), Column('name', String(50))) engineers = Table('engineers', metadata, - Column('person_id', Integer, ForeignKey('people.person_id'), + Column('person_id', Integer, ForeignKey('people.person_id'), primary_key=True), Column('field', String(30))) managers = Table('managers', metadata, - Column('person_id', Integer, ForeignKey('people.person_id'), + Column('person_id', Integer, ForeignKey('people.person_id'), primary_key=True), Column('category', String(70))) cars = Table('cars', metadata, - Column('car_id', Integer, primary_key=True, + Column('car_id', Integer, primary_key=True, test_needs_autoincrement=True), - Column('status_id', Integer, ForeignKey('status.status_id'), + Column('status_id', Integer, ForeignKey('status.status_id'), nullable=False), - Column('owner', Integer, ForeignKey('people.person_id'), + Column('owner', Integer, ForeignKey('people.person_id'), nullable=False)) metadata.create_all() @@ -868,18 +868,18 @@ class GenerativeTest(fixtures.TestBase, AssertsExecutionResults): status_mapper = mapper(Status, status) person_mapper = mapper(Person, people, - with_polymorphic=('*', employee_join), + with_polymorphic=('*', employee_join), polymorphic_on=employee_join.c.type, - polymorphic_identity='person', + polymorphic_identity='person', properties={'status':relationship(status_mapper)}) - engineer_mapper = mapper(Engineer, engineers, - inherits=person_mapper, + engineer_mapper = mapper(Engineer, engineers, + inherits=person_mapper, polymorphic_identity='engineer') - manager_mapper = mapper(Manager, managers, - inherits=person_mapper, + manager_mapper = mapper(Manager, managers, + inherits=person_mapper, polymorphic_identity='manager') car_mapper = mapper(Car, cars, properties= { - 'employee':relationship(person_mapper), + 'employee':relationship(person_mapper), 'status':relationship(status_mapper)}) session = create_session() @@ -891,10 +891,10 @@ class GenerativeTest(fixtures.TestBase, AssertsExecutionResults): session.add(dead) session.flush() - # TODO: we haven't created assertions for all + # TODO: we haven't created assertions for all # the data combinations created here - # creating 5 managers named from M1 to M5 + # creating 5 managers named from M1 to M5 # and 5 engineers named from E1 to E5 # M4, M5, E4 and E5 are dead for i in range(1,5): @@ -933,13 +933,13 @@ class GenerativeTest(fixtures.TestBase, AssertsExecutionResults): "status Status active]") r = session.query(Engineer).join('status').\ filter(Person.name.in_( - ['E2', 'E3', 'E4', 'M4', 'M2', 'M1']) & + ['E2', 'E3', 'E4', 'M4', 'M2', 'M1']) & (status.c.name=="active")).order_by(Person.name) eq_(str(list(r)), "[Engineer E2, field X, status Status " "active, Engineer E3, field X, status " "Status active]") - r = session.query(Person).filter(exists([1], + r = session.query(Person).filter(exists([1], Car.owner==Person.person_id)) eq_(str(list(r)), "[Engineer E4, field X, status Status dead]") @@ -949,20 +949,20 @@ class MultiLevelTest(fixtures.MappedTest): global table_Employee, table_Engineer, table_Manager table_Employee = Table( 'Employee', metadata, Column( 'name', type_= String(100), ), - Column( 'id', primary_key= True, type_= Integer, + Column( 'id', primary_key= True, type_= Integer, test_needs_autoincrement=True), Column( 'atype', type_= String(100), ), ) table_Engineer = Table( 'Engineer', metadata, Column( 'machine', type_= String(100), ), - Column( 'id', Integer, ForeignKey( 'Employee.id', ), + Column( 'id', Integer, ForeignKey( 'Employee.id', ), primary_key= True), ) table_Manager = Table( 'Manager', metadata, Column( 'duties', type_= String(100), ), - Column( 'id', Integer, ForeignKey( 'Engineer.id', ), + Column( 'id', Integer, ForeignKey( 'Engineer.id', ), primary_key= True, ), ) @@ -971,23 +971,23 @@ class MultiLevelTest(fixtures.MappedTest): def set( me, **kargs): for k,v in kargs.iteritems(): setattr( me, k, v) return me - def __str__(me): + def __str__(me): return str(me.__class__.__name__)+':'+str(me.name) __repr__ = __str__ - class Engineer(Employee): + class Engineer(Employee): pass - class Manager(Engineer): + class Manager(Engineer): pass pu_Employee = polymorphic_union( { - 'Manager': table_Employee.join( + 'Manager': table_Employee.join( table_Engineer).join( table_Manager), - 'Engineer': select([table_Employee, - table_Engineer.c.machine], - table_Employee.c.atype == 'Engineer', + 'Engineer': select([table_Employee, + table_Engineer.c.machine], + table_Employee.c.atype == 'Engineer', from_obj=[ table_Employee.join(table_Engineer)]), - 'Employee': table_Employee.select( + 'Employee': table_Employee.select( table_Employee.c.atype == 'Employee'), }, None, 'pu_employee', ) @@ -1000,9 +1000,9 @@ class MultiLevelTest(fixtures.MappedTest): pu_Engineer = polymorphic_union( { 'Manager': table_Employee.join( table_Engineer). join( table_Manager), - 'Engineer': select([table_Employee, - table_Engineer.c.machine], - table_Employee.c.atype == 'Engineer', + 'Engineer': select([table_Employee, + table_Engineer.c.machine], + table_Employee.c.atype == 'Engineer', from_obj=[ table_Employee.join(table_Engineer) ]), @@ -1025,7 +1025,7 @@ class MultiLevelTest(fixtures.MappedTest): a = Employee().set( name= 'one') b = Engineer().set( egn= 'two', machine= 'any') - c = Manager().set( name= 'head', machine= 'fast', + c = Manager().set( name= 'head', machine= 'fast', duties= 'many') session = create_session() @@ -1044,13 +1044,13 @@ class ManyToManyPolyTest(fixtures.MappedTest): collection_table base_item_table = Table( 'base_item', metadata, - Column('id', Integer, primary_key=True, + Column('id', Integer, primary_key=True, test_needs_autoincrement=True), Column('child_name', String(255), default=None)) item_table = Table( 'item', metadata, - Column('id', Integer, ForeignKey('base_item.id'), + Column('id', Integer, ForeignKey('base_item.id'), primary_key=True), Column('dummy', Integer, default=0)) @@ -1061,7 +1061,7 @@ class ManyToManyPolyTest(fixtures.MappedTest): collection_table = Table( 'collection', metadata, - Column('id', Integer, primary_key=True, + Column('id', Integer, primary_key=True, test_needs_autoincrement=True), Column('name', Unicode(255))) @@ -1084,8 +1084,8 @@ class ManyToManyPolyTest(fixtures.MappedTest): with_polymorphic=('*', item_join), polymorphic_on=base_item_table.c.child_name, polymorphic_identity='BaseItem', - properties=dict(collections=relationship(Collection, - secondary=base_item_collection_table, + properties=dict(collections=relationship(Collection, + secondary=base_item_collection_table, backref="items"))) mapper( @@ -1102,7 +1102,7 @@ class CustomPKTest(fixtures.MappedTest): def define_tables(cls, metadata): global t1, t2 t1 = Table('t1', metadata, - Column('id', Integer, primary_key=True, + Column('id', Integer, primary_key=True, test_needs_autoincrement=True), Column('type', String(30), nullable=False), Column('data', String(30))) @@ -1127,9 +1127,9 @@ class CustomPKTest(fixtures.MappedTest): d['t2'] = t1.join(t2) pjoin = polymorphic_union(d, None, 'pjoin') - mapper(T1, t1, polymorphic_on=t1.c.type, - polymorphic_identity='t1', - with_polymorphic=('*', pjoin), + mapper(T1, t1, polymorphic_on=t1.c.type, + polymorphic_identity='t1', + with_polymorphic=('*', pjoin), primary_key=[pjoin.c.id]) mapper(T2, t2, inherits=T1, polymorphic_identity='t2') ot1 = T1() @@ -1140,7 +1140,7 @@ class CustomPKTest(fixtures.MappedTest): sess.flush() sess.expunge_all() - # query using get(), using only one value. + # query using get(), using only one value. # this requires the select_table mapper # has the same single-col primary key. assert sess.query(T1).get(ot1.id).id == ot1.id @@ -1165,8 +1165,8 @@ class CustomPKTest(fixtures.MappedTest): d['t2'] = t1.join(t2) pjoin = polymorphic_union(d, None, 'pjoin') - mapper(T1, t1, polymorphic_on=t1.c.type, - polymorphic_identity='t1', + mapper(T1, t1, polymorphic_on=t1.c.type, + polymorphic_identity='t1', with_polymorphic=('*', pjoin)) mapper(T2, t2, inherits=T1, polymorphic_identity='t2') assert len(class_mapper(T1).primary_key) == 1 @@ -1179,7 +1179,7 @@ class CustomPKTest(fixtures.MappedTest): sess.flush() sess.expunge_all() - # query using get(), using only one value. this requires the + # query using get(), using only one value. this requires the # select_table mapper # has the same single-col primary key. assert sess.query(T1).get(ot1.id).id == ot1.id @@ -1194,7 +1194,7 @@ class InheritingEagerTest(fixtures.MappedTest): global people, employees, tags, peopleTags people = Table('people', metadata, - Column('id', Integer, primary_key=True, + Column('id', Integer, primary_key=True, test_needs_autoincrement=True), Column('_type', String(30), nullable=False), ) @@ -1206,7 +1206,7 @@ class InheritingEagerTest(fixtures.MappedTest): ) tags = Table('tags', metadata, - Column('id', Integer, primary_key=True, + Column('id', Integer, primary_key=True, test_needs_autoincrement=True), Column('label', String(50), nullable=False), ) @@ -1233,10 +1233,10 @@ class InheritingEagerTest(fixtures.MappedTest): def __init__(self, label): self.label = label - mapper(Person, people, polymorphic_on=people.c._type, + mapper(Person, people, polymorphic_on=people.c._type, polymorphic_identity='person', properties={ - 'tags': relationship(Tag, - secondary=peopleTags, + 'tags': relationship(Tag, + secondary=peopleTags, backref='people', lazy='joined') }) mapper(Employee, employees, inherits=Person, @@ -1264,24 +1264,24 @@ class InheritingEagerTest(fixtures.MappedTest): class MissingPolymorphicOnTest(fixtures.MappedTest): @classmethod def define_tables(cls, metadata): - tablea = Table('tablea', metadata, - Column('id', Integer, primary_key=True, + tablea = Table('tablea', metadata, + Column('id', Integer, primary_key=True, test_needs_autoincrement=True), Column('adata', String(50)), ) - tableb = Table('tableb', metadata, - Column('id', Integer, primary_key=True, + tableb = Table('tableb', metadata, + Column('id', Integer, primary_key=True, test_needs_autoincrement=True), Column('aid', Integer, ForeignKey('tablea.id')), Column('data', String(50)), ) - tablec = Table('tablec', metadata, - Column('id', Integer, ForeignKey('tablea.id'), + tablec = Table('tablec', metadata, + Column('id', Integer, ForeignKey('tablea.id'), primary_key=True), Column('cdata', String(50)), ) - tabled = Table('tabled', metadata, - Column('id', Integer, ForeignKey('tablec.id'), + tabled = Table('tabled', metadata, + Column('id', Integer, ForeignKey('tablec.id'), primary_key=True), Column('ddata', String(50)), ) @@ -1303,13 +1303,13 @@ class MissingPolymorphicOnTest(fixtures.MappedTest): A, B, C, D = self.classes.A, self.classes.B, self.classes.C, \ self.classes.D poly_select = select( - [tablea, tableb.c.data.label('discriminator')], + [tablea, tableb.c.data.label('discriminator')], from_obj=tablea.join(tableb)).alias('poly') mapper(B, tableb) - mapper(A, tablea, + mapper(A, tablea, with_polymorphic=('*', poly_select), - polymorphic_on=poly_select.c.discriminator, + polymorphic_on=poly_select.c.discriminator, properties={ 'b':relationship(B, uselist=False) }) @@ -1324,9 +1324,9 @@ class MissingPolymorphicOnTest(fixtures.MappedTest): sess.flush() sess.expunge_all() eq_( - sess.query(A).all(), + sess.query(A).all(), [ - C(cdata='c1', adata='a1'), + C(cdata='c1', adata='a1'), D(cdata='c2', adata='a2', ddata='d2') ] ) @@ -1335,17 +1335,17 @@ class JoinedInhAdjacencyTest(fixtures.MappedTest): @classmethod def define_tables(cls, metadata): Table('people', metadata, - Column('id', Integer, primary_key=True, + Column('id', Integer, primary_key=True, test_needs_autoincrement=True), Column('type', String(30)), ) Table('users', metadata, - Column('id', Integer, ForeignKey('people.id'), + Column('id', Integer, ForeignKey('people.id'), primary_key=True), Column('supervisor_id', Integer, ForeignKey('people.id')), ) Table('dudes', metadata, - Column('id', Integer, ForeignKey('users.id'), + Column('id', Integer, ForeignKey('users.id'), primary_key=True), ) @@ -1463,13 +1463,13 @@ class Ticket2419Test(fixtures.DeclarativeMappedTest): class A(Base): __tablename__ = "a" - id = Column(Integer, primary_key=True, + id = Column(Integer, primary_key=True, test_needs_autoincrement=True) class B(Base): __tablename__ = "b" - id = Column(Integer, primary_key=True, + id = Column(Integer, primary_key=True, test_needs_autoincrement=True) ds = relationship("D") es = relationship("E") @@ -1494,7 +1494,7 @@ class Ticket2419Test(fixtures.DeclarativeMappedTest): test_needs_autoincrement=True) b_id = Column(Integer, ForeignKey('b.id')) - @testing.fails_on("oracle", + @testing.fails_on("oracle", "seems like oracle's query engine can't " "handle this, not clear if there's an " "expression-level bug on our end though") diff --git a/test/orm/inheritance/test_magazine.py b/test/orm/inheritance/test_magazine.py index 840270e58..a1118aa86 100644 --- a/test/orm/inheritance/test_magazine.py +++ b/test/orm/inheritance/test_magazine.py @@ -176,10 +176,10 @@ def _generate_round_trip_test(use_unions=False, use_joins=False): 'magazine': relationship(Magazine, backref=backref('pages', order_by=page_table.c.page_no)) }) - classified_page_mapper = mapper(ClassifiedPage, - classified_page_table, - inherits=magazine_page_mapper, - polymorphic_identity='c', + classified_page_mapper = mapper(ClassifiedPage, + classified_page_table, + inherits=magazine_page_mapper, + polymorphic_identity='c', primary_key=[page_table.c.id]) diff --git a/test/orm/inheritance/test_poly_persistence.py b/test/orm/inheritance/test_poly_persistence.py index 6939479b1..5b5844b70 100644 --- a/test/orm/inheritance/test_poly_persistence.py +++ b/test/orm/inheritance/test_poly_persistence.py @@ -27,20 +27,20 @@ class PolymorphTest(fixtures.MappedTest): global companies, people, engineers, managers, boss companies = Table('companies', metadata, - Column('company_id', Integer, primary_key=True, + Column('company_id', Integer, primary_key=True, test_needs_autoincrement=True), Column('name', String(50))) people = Table('people', metadata, - Column('person_id', Integer, primary_key=True, + Column('person_id', Integer, primary_key=True, test_needs_autoincrement=True), - Column('company_id', Integer, ForeignKey('companies.company_id'), + Column('company_id', Integer, ForeignKey('companies.company_id'), nullable=False), Column('name', String(50)), Column('type', String(30))) engineers = Table('engineers', metadata, - Column('person_id', Integer, ForeignKey('people.person_id'), + Column('person_id', Integer, ForeignKey('people.person_id'), primary_key=True), Column('status', String(30)), Column('engineer_name', String(50)), @@ -48,14 +48,14 @@ class PolymorphTest(fixtures.MappedTest): ) managers = Table('managers', metadata, - Column('person_id', Integer, ForeignKey('people.person_id'), + Column('person_id', Integer, ForeignKey('people.person_id'), primary_key=True), Column('status', String(30)), Column('manager_name', String(50)) ) boss = Table('boss', metadata, - Column('boss_id', Integer, ForeignKey('managers.person_id'), + Column('boss_id', Integer, ForeignKey('managers.person_id'), primary_key=True), Column('golf_swing', String(30)), ) @@ -74,14 +74,14 @@ class InsertOrderTest(PolymorphTest): 'person':people.select(people.c.type=='person'), }, None, 'pjoin') - person_mapper = mapper(Person, people, - with_polymorphic=('*', person_join), - polymorphic_on=person_join.c.type, + person_mapper = mapper(Person, people, + with_polymorphic=('*', person_join), + polymorphic_on=person_join.c.type, polymorphic_identity='person') - mapper(Engineer, engineers, inherits=person_mapper, + mapper(Engineer, engineers, inherits=person_mapper, polymorphic_identity='engineer') - mapper(Manager, managers, inherits=person_mapper, + mapper(Manager, managers, inherits=person_mapper, polymorphic_identity='manager') mapper(Company, companies, properties={ 'employees': relationship(Person, @@ -113,16 +113,16 @@ class RoundTripTest(PolymorphTest): def _generate_round_trip_test(include_base, lazy_relationship, redefine_colprop, with_polymorphic): """generates a round trip test. - + include_base - whether or not to include the base 'person' type in the union. - + lazy_relationship - whether or not the Company relationship to People is lazy or eager. - + redefine_colprop - if we redefine the 'name' column to be 'people_name' on the base Person class - + use_literal_join - primary join condition is explicitly specified """ def test_roundtrip(self): @@ -158,21 +158,21 @@ def _generate_round_trip_test(include_base, lazy_relationship, manager_with_polymorphic = None if redefine_colprop: - person_mapper = mapper(Person, people, - with_polymorphic=person_with_polymorphic, - polymorphic_on=people.c.type, - polymorphic_identity='person', + person_mapper = mapper(Person, people, + with_polymorphic=person_with_polymorphic, + polymorphic_on=people.c.type, + polymorphic_identity='person', properties= {'person_name':people.c.name}) else: - person_mapper = mapper(Person, people, - with_polymorphic=person_with_polymorphic, - polymorphic_on=people.c.type, + person_mapper = mapper(Person, people, + with_polymorphic=person_with_polymorphic, + polymorphic_on=people.c.type, polymorphic_identity='person') - mapper(Engineer, engineers, inherits=person_mapper, + mapper(Engineer, engineers, inherits=person_mapper, polymorphic_identity='engineer') - mapper(Manager, managers, inherits=person_mapper, - with_polymorphic=manager_with_polymorphic, + mapper(Manager, managers, inherits=person_mapper, + with_polymorphic=manager_with_polymorphic, polymorphic_identity='manager') mapper(Boss, boss, inherits=Manager, polymorphic_identity='boss') @@ -190,19 +190,19 @@ def _generate_round_trip_test(include_base, lazy_relationship, person_attribute_name = 'name' employees = [ - Manager(status='AAB', manager_name='manager1', + Manager(status='AAB', manager_name='manager1', **{person_attribute_name:'pointy haired boss'}), - Engineer(status='BBA', engineer_name='engineer1', - primary_language='java', + Engineer(status='BBA', engineer_name='engineer1', + primary_language='java', **{person_attribute_name:'dilbert'}), ] if include_base: employees.append(Person(**{person_attribute_name:'joesmith'})) employees += [ - Engineer(status='CGG', engineer_name='engineer2', - primary_language='python', + Engineer(status='CGG', engineer_name='engineer2', + primary_language='python', **{person_attribute_name:'wally'}), - Manager(status='ABA', manager_name='manager2', + Manager(status='ABA', manager_name='manager2', **{person_attribute_name:'jsmith'}) ] @@ -222,7 +222,7 @@ def _generate_round_trip_test(include_base, lazy_relationship, session.expunge_all() eq_(session.query(Person).filter( - Person.person_id==dilbert.person_id).one(), + Person.person_id==dilbert.person_id).one(), dilbert) session.expunge_all() @@ -242,9 +242,9 @@ def _generate_round_trip_test(include_base, lazy_relationship, else: self.assert_sql_count(testing.db, go, 6) - # test selecting from the query, using the base + # test selecting from the query, using the base # mapped table (people) as the selection criterion. - # in the case of the polymorphic Person query, + # in the case of the polymorphic Person query, # the "people" selectable should be adapted to be "person_join" eq_( session.query(Person).filter( @@ -264,9 +264,9 @@ def _generate_round_trip_test(include_base, lazy_relationship, dilbert ) - # test selecting from the query, joining against + # test selecting from the query, joining against # an alias of the base "people" table. test that - # the "palias" alias does *not* get sucked up + # the "palias" alias does *not* get sucked up # into the "person_join" conversion. palias = people.alias("palias") dilbert = session.query(Person).get(dilbert.person_id) @@ -287,35 +287,35 @@ def _generate_round_trip_test(include_base, lazy_relationship, session.expunge_all() def go(): - session.query(Person).filter(getattr(Person, + session.query(Person).filter(getattr(Person, person_attribute_name)=='dilbert').first() self.assert_sql_count(testing.db, go, 1) session.expunge_all() - dilbert = session.query(Person).filter(getattr(Person, + dilbert = session.query(Person).filter(getattr(Person, person_attribute_name)=='dilbert').first() def go(): - # assert that only primary table is queried for + # assert that only primary table is queried for # already-present-in-session - d = session.query(Person).filter(getattr(Person, + d = session.query(Person).filter(getattr(Person, person_attribute_name)=='dilbert').first() self.assert_sql_count(testing.db, go, 1) # test standalone orphans - daboss = Boss(status='BBB', - manager_name='boss', - golf_swing='fore', + daboss = Boss(status='BBB', + manager_name='boss', + golf_swing='fore', **{person_attribute_name:'daboss'}) session.add(daboss) assert_raises(sa_exc.DBAPIError, session.flush) c = session.query(Company).first() daboss.company = c - manager_list = [e for e in c.employees + manager_list = [e for e in c.employees if isinstance(e, Manager)] session.flush() session.expunge_all() - eq_(session.query(Manager).order_by(Manager.person_id).all(), + eq_(session.query(Manager).order_by(Manager.person_id).all(), manager_list) c = session.query(Company).first() @@ -337,11 +337,11 @@ for lazy_relationship in [True, False]: for with_polymorphic in ['unions', 'joins', 'auto', 'none']: if with_polymorphic == 'unions': for include_base in [True, False]: - _generate_round_trip_test(include_base, - lazy_relationship, + _generate_round_trip_test(include_base, + lazy_relationship, redefine_colprop, with_polymorphic) else: - _generate_round_trip_test(False, - lazy_relationship, + _generate_round_trip_test(False, + lazy_relationship, redefine_colprop, with_polymorphic) diff --git a/test/orm/inheritance/test_polymorphic_rel.py b/test/orm/inheritance/test_polymorphic_rel.py index 50593d39c..6d7bcb676 100644 --- a/test/orm/inheritance/test_polymorphic_rel.py +++ b/test/orm/inheritance/test_polymorphic_rel.py @@ -39,7 +39,7 @@ class _PolymorphicTestBase(object): def test_loads_at_once(self): """ - Test that all objects load from the full query, when + Test that all objects load from the full query, when with_polymorphic is used. """ @@ -50,7 +50,7 @@ class _PolymorphicTestBase(object): self.assert_sql_count(testing.db, go, count) def test_primary_eager_aliasing_one(self): - # For both joinedload() and subqueryload(), if the original q is + # For both joinedload() and subqueryload(), if the original q is # not loading the subclass table, the joinedload doesn't happen. sess = create_session() @@ -89,7 +89,7 @@ class _PolymorphicTestBase(object): def test_get_one(self): """ - For all mappers, ensure the primary key has been calculated as + For all mappers, ensure the primary key has been calculated as just the "person_id" column. """ sess = create_session() @@ -405,7 +405,7 @@ class _PolymorphicTestBase(object): def test_join_from_columns_or_subclass_six(self): sess = create_session() if self.select_type == '': - # this now raises, due to [ticket:1892]. Manager.person_id + # this now raises, due to [ticket:1892]. Manager.person_id # is now the "person_id" column on Manager. SQL is incorrect. assert_raises( sa_exc.DBAPIError, @@ -414,8 +414,8 @@ class _PolymorphicTestBase(object): Manager.person_id == paperwork.c.person_id) .order_by(Person.name).all) elif self.select_type == 'Unions': - # with the union, not something anyone would really be using - # here, it joins to the full result set. This is 0.6's + # with the union, not something anyone would really be using + # here, it joins to the full result set. This is 0.6's # behavior and is more or less wrong. expected = [ (u'dilbert',), @@ -432,7 +432,7 @@ class _PolymorphicTestBase(object): .order_by(Person.name).all(), expected) else: - # when a join is present and managers.person_id is available, + # when a join is present and managers.person_id is available, # you get the managers. expected = [ (u'dogbert',), @@ -501,7 +501,7 @@ class _PolymorphicTestBase(object): # need it anymore. def test_polymorphic_option(self): """ - Test that polymorphic loading sets state.load_path with its + Test that polymorphic loading sets state.load_path with its actual mapper on a subclass, and not the superclass mapper. This only works for non-aliased mappers. @@ -540,7 +540,7 @@ class _PolymorphicTestBase(object): def test_expire(self): """ - Test that individual column refresh doesn't get tripped up by + Test that individual column refresh doesn't get tripped up by the select_table mapper. """ @@ -596,7 +596,7 @@ class _PolymorphicTestBase(object): def test_with_polymorphic_five(self): sess = create_session() def go(): - # limit the polymorphic join down to just "Person", + # limit the polymorphic join down to just "Person", # overriding select_table eq_(sess.query(Person) .with_polymorphic(Person).all(), @@ -615,7 +615,7 @@ class _PolymorphicTestBase(object): def test_with_polymorphic_seven(self): sess = create_session() - # compare to entities without related collections to prevent + # compare to entities without related collections to prevent # additional lazy SQL from firing on loaded entities eq_(sess.query(Person).with_polymorphic('*').all(), self._emps_wo_relationships_fixture()) @@ -673,8 +673,8 @@ class _PolymorphicTestBase(object): # query one is company->Person/Engineer->Machines # query two is Person/Engineer subq - # query three is Machines subq - # (however this test can't tell if the Q was a + # query three is Machines subq + # (however this test can't tell if the Q was a # lazyload or subqload ...) # query four is managers + boss for row #3 # query five is managers for row #4 @@ -940,8 +940,8 @@ class _PolymorphicTestBase(object): .filter(Engineer.engineer_name == 'vlad').one(), c2) - # same, using explicit join condition. Query.join() must - # adapt the on clause here to match the subquery wrapped around + # same, using explicit join condition. Query.join() must + # adapt the on clause here to match the subquery wrapped around # "people join engineers". eq_(sess.query(Company) .join(Engineer, Company.company_id == Engineer.company_id) @@ -984,10 +984,10 @@ class _PolymorphicTestBase(object): expected) def test_nesting_queries(self): - # query.statement places a flag "no_adapt" on the returned - # statement. This prevents the polymorphic adaptation in the - # second "filter" from hitting it, which would pollute the - # subquery and usually results in recursion overflow errors + # query.statement places a flag "no_adapt" on the returned + # statement. This prevents the polymorphic adaptation in the + # second "filter" from hitting it, which would pollute the + # subquery and usually results in recursion overflow errors # within the adaption. sess = create_session() subq = (sess.query(engineers.c.person_id) @@ -1159,8 +1159,8 @@ class _PolymorphicTestBase(object): #def test_mixed_entities(self): # sess = create_session() - # TODO: I think raise error on these for now. different - # inheritance/loading schemes have different results here, + # TODO: I think raise error on these for now. different + # inheritance/loading schemes have different results here, # all incorrect # # eq_( @@ -1170,8 +1170,8 @@ class _PolymorphicTestBase(object): #def test_mixed_entities(self): # sess = create_session() # eq_(sess.query( - # Person.name, - # Engineer.primary_language, + # Person.name, + # Engineer.primary_language, # Manager.manager_name) # .all(), # []) diff --git a/test/orm/inheritance/test_relationship.py b/test/orm/inheritance/test_relationship.py index 8db5f6b3b..a4e19b988 100644 --- a/test/orm/inheritance/test_relationship.py +++ b/test/orm/inheritance/test_relationship.py @@ -562,7 +562,7 @@ class SelfReferentialM2MTest(fixtures.MappedTest, AssertsCompiledSQL): sess.add(c1) sess.flush() - # test that the splicing of the join works here, doesn't break in + # test that the splicing of the join works here, doesn't break in # the middle of "parent join child1" q = sess.query(Child1).options(joinedload('left_child2')) self.assert_compile(q.limit(1).with_labels().statement, diff --git a/test/orm/inheritance/test_single.py b/test/orm/inheritance/test_single.py index d05551ef4..774626c48 100644 --- a/test/orm/inheritance/test_single.py +++ b/test/orm/inheritance/test_single.py @@ -93,7 +93,7 @@ class SingleInheritanceTest(testing.AssertsCompiledSQL, fixtures.MappedTest): ealias = aliased(Engineer) eq_( - session.query(Manager, ealias).all(), + session.query(Manager, ealias).all(), [(m1, e1), (m1, e2)] ) @@ -124,7 +124,7 @@ class SingleInheritanceTest(testing.AssertsCompiledSQL, fixtures.MappedTest): # TODO: I think raise error on this for now # self.assertEquals( - # session.query(Employee.name, Manager.manager_data, Engineer.engineer_info).all(), + # session.query(Employee.name, Manager.manager_data, Engineer.engineer_info).all(), # [] # ) @@ -169,7 +169,7 @@ class SingleInheritanceTest(testing.AssertsCompiledSQL, fixtures.MappedTest): sess.flush() eq_( - sess.query(Manager).select_from(employees.select().limit(10)).all(), + sess.query(Manager).select_from(employees.select().limit(10)).all(), [m1, m2] ) @@ -389,7 +389,7 @@ class RelationshipToSingleTest(testing.AssertsCompiledSQL, fixtures.MappedTest): "SELECT companies.company_id AS companies_company_id, " "companies.name AS companies_name, employees.name AS employees_name " "FROM companies LEFT OUTER JOIN employees ON companies.company_id " - "= employees.company_id AND employees.type IN (:type_1)" + "= employees.company_id AND employees.type IN (:type_1)" ) def test_outer_join_alias(self): @@ -450,7 +450,7 @@ class RelationshipToSingleTest(testing.AssertsCompiledSQL, fixtures.MappedTest): eq_(c2.engineers, [e1]) sess.expunge_all() - eq_(sess.query(Company).order_by(Company.name).all(), + eq_(sess.query(Company).order_by(Company.name).all(), [ Company(name='c1', engineers=[JuniorEngineer(name='Ed')]), Company(name='c2', engineers=[Engineer(name='Kurt')]) @@ -459,7 +459,7 @@ class RelationshipToSingleTest(testing.AssertsCompiledSQL, fixtures.MappedTest): # eager load join should limit to only "Engineer" sess.expunge_all() - eq_(sess.query(Company).options(joinedload('engineers')).order_by(Company.name).all(), + eq_(sess.query(Company).options(joinedload('engineers')).order_by(Company.name).all(), [ Company(name='c1', engineers=[JuniorEngineer(name='Ed')]), Company(name='c2', engineers=[Engineer(name='Kurt')]) diff --git a/test/orm/inheritance/test_with_poly.py b/test/orm/inheritance/test_with_poly.py index d0de0aa22..dc0035b6a 100644 --- a/test/orm/inheritance/test_with_poly.py +++ b/test/orm/inheritance/test_with_poly.py @@ -32,12 +32,12 @@ class _WithPolymorphicBase(_PolymorphicFixtureBase): eq_( sess.query(pa.name, pa.Engineer.primary_language, pa.Manager.manager_name).\ - filter(or_(pa.Engineer.primary_language=='java', + filter(or_(pa.Engineer.primary_language=='java', pa.Manager.manager_name=='dogbert')).\ order_by(pa.Engineer.type).all(), [ (u'dilbert', u'java', None), - (u'dogbert', None, u'dogbert'), + (u'dogbert', None, u'dogbert'), ] ) @@ -50,7 +50,7 @@ class _WithPolymorphicBase(_PolymorphicFixtureBase): eq_( [(p1.name, type(p1), p2.name, type(p2)) for (p1, p2) in sess.query( pa, pa_alias - ).join(pa_alias, + ).join(pa_alias, or_( pa.Engineer.primary_language==\ pa_alias.Engineer.primary_language, @@ -62,9 +62,9 @@ class _WithPolymorphicBase(_PolymorphicFixtureBase): ) ).order_by(pa.name, pa_alias.name)], [ - (u'dilbert', Engineer, u'dilbert', Engineer), - (u'dogbert', Manager, u'pointy haired boss', Boss), - (u'vlad', Engineer, u'vlad', Engineer), + (u'dilbert', Engineer, u'dilbert', Engineer), + (u'dogbert', Manager, u'pointy haired boss', Boss), + (u'vlad', Engineer, u'vlad', Engineer), (u'wally', Engineer, u'wally', Engineer) ] ) @@ -76,9 +76,9 @@ class _WithPolymorphicBase(_PolymorphicFixtureBase): eq_( [row for row in sess.query( - pa.name, pa.Engineer.primary_language, + pa.name, pa.Engineer.primary_language, pa_alias.name, pa_alias.Engineer.primary_language - ).join(pa_alias, + ).join(pa_alias, or_( pa.Engineer.primary_language==\ pa_alias.Engineer.primary_language, @@ -90,9 +90,9 @@ class _WithPolymorphicBase(_PolymorphicFixtureBase): ) ).order_by(pa.name, pa_alias.name)], [ - (u'dilbert', u'java', u'dilbert', u'java'), - (u'dogbert', None, u'pointy haired boss', None), - (u'vlad', u'cobol', u'vlad', u'cobol'), + (u'dilbert', u'java', u'dilbert', u'java'), + (u'dogbert', None, u'pointy haired boss', None), + (u'vlad', u'cobol', u'vlad', u'cobol'), (u'wally', u'c++', u'wally', u'c++') ] ) diff --git a/test/orm/test_assorted_eager.py b/test/orm/test_assorted_eager.py index 2eddfde9c..dded00256 100644 --- a/test/orm/test_assorted_eager.py +++ b/test/orm/test_assorted_eager.py @@ -2,7 +2,7 @@ Derived from mailing list-reported problems and trac tickets. -These are generally very old 0.1-era tests and at some point should +These are generally very old 0.1-era tests and at some point should be cleaned up and modernized. """ diff --git a/test/orm/test_backref_mutations.py b/test/orm/test_backref_mutations.py index b3214984f..7e425a457 100644 --- a/test/orm/test_backref_mutations.py +++ b/test/orm/test_backref_mutations.py @@ -121,7 +121,7 @@ class O2MCollectionTest(_fixtures.FixtureTest): # backref fires assert a1.user is u2 - # everything expires, no changes in + # everything expires, no changes in # u1.addresses, so all is fine sess.commit() assert a1 not in u1.addresses @@ -143,7 +143,7 @@ class O2MCollectionTest(_fixtures.FixtureTest): u1.addresses # direct set - the "old" is "fetched", - # but only from the local session - not the + # but only from the local session - not the # database, due to the PASSIVE_NO_FETCH flag. # this is a more fine grained behavior introduced # in 0.6 @@ -207,7 +207,7 @@ class O2MCollectionTest(_fixtures.FixtureTest): sess.add_all([u1, u2, a1]) sess.commit() - # direct set - the fetching of the + # direct set - the fetching of the # "old" u1 here allows the backref # to remove it from the addresses collection a1.user = u2 @@ -230,7 +230,7 @@ class O2MCollectionTest(_fixtures.FixtureTest): # u1.addresses is loaded u1.addresses - # direct set - the fetching of the + # direct set - the fetching of the # "old" u1 here allows the backref # to remove it from the addresses collection a1.user = u2 @@ -455,8 +455,8 @@ class O2OScalarOrphanTest(_fixtures.FixtureTest): mapper(Address, addresses) mapper(User, users, properties = { - 'address':relationship(Address, uselist=False, - backref=backref('user', single_parent=True, + 'address':relationship(Address, uselist=False, + backref=backref('user', single_parent=True, cascade="all, delete-orphan")) }) @@ -491,7 +491,7 @@ class M2MCollectionMoveTest(_fixtures.FixtureTest): cls.classes.Item) mapper(Item, items, properties={ - 'keywords':relationship(Keyword, secondary=item_keywords, + 'keywords':relationship(Keyword, secondary=item_keywords, backref='items') }) mapper(Keyword, keywords) @@ -603,8 +603,8 @@ class M2MScalarMoveTest(_fixtures.FixtureTest): cls.classes.Item) mapper(Item, items, properties={ - 'keyword':relationship(Keyword, secondary=item_keywords, - uselist=False, + 'keyword':relationship(Keyword, secondary=item_keywords, + uselist=False, backref=backref("item", uselist=False)) }) mapper(Keyword, keywords) @@ -718,7 +718,7 @@ class M2MStaleBackrefTest(_fixtures.FixtureTest): cls.classes.Item) mapper(Item, items, properties={ - 'keywords':relationship(Keyword, secondary=item_keywords, + 'keywords':relationship(Keyword, secondary=item_keywords, backref='items') }) mapper(Keyword, keywords) diff --git a/test/orm/test_cascade.py b/test/orm/test_cascade.py index 3edf8af65..20088c070 100644 --- a/test/orm/test_cascade.py +++ b/test/orm/test_cascade.py @@ -65,7 +65,7 @@ class CascadeArgTest(fixtures.MappedTest): def test_cascade_immutable(self): assert isinstance( - orm_util.CascadeOptions("all, delete-orphan"), + orm_util.CascadeOptions("all, delete-orphan"), frozenset) class O2MCascadeDeleteOrphanTest(fixtures.MappedTest): @@ -388,7 +388,7 @@ class O2MCascadeTest(fixtures.MappedTest): @classmethod def setup_mappers(cls): users, User, Address, addresses = ( - cls.tables.users, cls.classes.User, + cls.tables.users, cls.classes.User, cls.classes.Address, cls.tables.addresses) mapper(Address, addresses) @@ -508,8 +508,8 @@ class NoSaveCascadeFlushTest(_fixtures.FixtureTest): run_inserts = None - def _one_to_many_fixture(self, o2m_cascade=True, - m2o_cascade=True, + def _one_to_many_fixture(self, o2m_cascade=True, + m2o_cascade=True, o2m=False, m2o=False, o2m_cascade_backrefs=True, @@ -523,10 +523,10 @@ class NoSaveCascadeFlushTest(_fixtures.FixtureTest): if o2m: if m2o: addresses_rel = {'addresses':relationship( - Address, + Address, cascade_backrefs=o2m_cascade_backrefs, cascade=o2m_cascade and 'save-update' or '', - backref=backref('user', + backref=backref('user', cascade=m2o_cascade and 'save-update' or '', cascade_backrefs=m2o_cascade_backrefs ) @@ -534,7 +534,7 @@ class NoSaveCascadeFlushTest(_fixtures.FixtureTest): else: addresses_rel = {'addresses':relationship( - Address, + Address, cascade=o2m_cascade and 'save-update' or '', cascade_backrefs=o2m_cascade_backrefs, )} @@ -552,8 +552,8 @@ class NoSaveCascadeFlushTest(_fixtures.FixtureTest): mapper(User, users, properties=addresses_rel) mapper(Address, addresses, properties=user_rel) - def _many_to_many_fixture(self, fwd_cascade=True, - bkd_cascade=True, + def _many_to_many_fixture(self, fwd_cascade=True, + bkd_cascade=True, fwd=False, bkd=False, fwd_cascade_backrefs=True, @@ -568,11 +568,11 @@ class NoSaveCascadeFlushTest(_fixtures.FixtureTest): if fwd: if bkd: keywords_rel = {'keywords':relationship( - Keyword, + Keyword, secondary=item_keywords, cascade_backrefs=fwd_cascade_backrefs, cascade=fwd_cascade and 'save-update' or '', - backref=backref('items', + backref=backref('items', cascade=bkd_cascade and 'save-update' or '', cascade_backrefs=bkd_cascade_backrefs ) @@ -580,7 +580,7 @@ class NoSaveCascadeFlushTest(_fixtures.FixtureTest): else: keywords_rel = {'keywords':relationship( - Keyword, + Keyword, secondary=item_keywords, cascade=fwd_cascade and 'save-update' or '', cascade_backrefs=fwd_cascade_backrefs, @@ -664,7 +664,7 @@ class NoSaveCascadeFlushTest(_fixtures.FixtureTest): def test_o2m_backref_child_transient(self): User, Address = self.classes.User, self.classes.Address - self._one_to_many_fixture(o2m=True, m2o=True, + self._one_to_many_fixture(o2m=True, m2o=True, o2m_cascade=False) sess = Session() u1 = User(name='u1') @@ -680,7 +680,7 @@ class NoSaveCascadeFlushTest(_fixtures.FixtureTest): def test_o2m_backref_child_transient_nochange(self): User, Address = self.classes.User, self.classes.Address - self._one_to_many_fixture(o2m=True, m2o=True, + self._one_to_many_fixture(o2m=True, m2o=True, o2m_cascade=False) sess = Session() u1 = User(name='u1') @@ -698,7 +698,7 @@ class NoSaveCascadeFlushTest(_fixtures.FixtureTest): def test_o2m_backref_child_expunged(self): User, Address = self.classes.User, self.classes.Address - self._one_to_many_fixture(o2m=True, m2o=True, + self._one_to_many_fixture(o2m=True, m2o=True, o2m_cascade=False) sess = Session() u1 = User(name='u1') @@ -718,7 +718,7 @@ class NoSaveCascadeFlushTest(_fixtures.FixtureTest): def test_o2m_backref_child_expunged_nochange(self): User, Address = self.classes.User, self.classes.Address - self._one_to_many_fixture(o2m=True, m2o=True, + self._one_to_many_fixture(o2m=True, m2o=True, o2m_cascade=False) sess = Session() u1 = User(name='u1') @@ -936,7 +936,7 @@ class NoSaveCascadeFlushTest(_fixtures.FixtureTest): def test_m2m_backref_child_transient(self): Item, Keyword = self.classes.Item, self.classes.Keyword - self._many_to_many_fixture(fwd=True, bkd=True, + self._many_to_many_fixture(fwd=True, bkd=True, fwd_cascade=False) sess = Session() i1 = Item(description='i1') @@ -952,7 +952,7 @@ class NoSaveCascadeFlushTest(_fixtures.FixtureTest): def test_m2m_backref_child_transient_nochange(self): Item, Keyword = self.classes.Item, self.classes.Keyword - self._many_to_many_fixture(fwd=True, bkd=True, + self._many_to_many_fixture(fwd=True, bkd=True, fwd_cascade=False) sess = Session() i1 = Item(description='i1') @@ -970,7 +970,7 @@ class NoSaveCascadeFlushTest(_fixtures.FixtureTest): def test_m2m_backref_child_expunged(self): Item, Keyword = self.classes.Item, self.classes.Keyword - self._many_to_many_fixture(fwd=True, bkd=True, + self._many_to_many_fixture(fwd=True, bkd=True, fwd_cascade=False) sess = Session() i1 = Item(description='i1') @@ -990,7 +990,7 @@ class NoSaveCascadeFlushTest(_fixtures.FixtureTest): def test_m2m_backref_child_expunged_nochange(self): Item, Keyword = self.classes.Item, self.classes.Keyword - self._many_to_many_fixture(fwd=True, bkd=True, + self._many_to_many_fixture(fwd=True, bkd=True, fwd_cascade=False) sess = Session() i1 = Item(description='i1') @@ -1433,19 +1433,19 @@ class M2OCascadeDeleteNoOrphanTest(fixtures.MappedTest): @classmethod def define_tables(cls, metadata): Table('t1', metadata, Column('id', Integer, primary_key=True, - test_needs_autoincrement=True), - Column('data',String(50)), + test_needs_autoincrement=True), + Column('data',String(50)), Column('t2id', Integer, ForeignKey('t2.id'))) - Table('t2', metadata, + Table('t2', metadata, Column('id', Integer, primary_key=True, - test_needs_autoincrement=True), - Column('data',String(50)), + test_needs_autoincrement=True), + Column('data',String(50)), Column('t3id', Integer, ForeignKey('t3.id'))) - Table('t3', metadata, + Table('t3', metadata, Column('id', Integer, primary_key=True, - test_needs_autoincrement=True), + test_needs_autoincrement=True), Column('data', String(50))) @classmethod @@ -1734,7 +1734,7 @@ class M2MCascadeTest(fixtures.MappedTest): self.tables.atob) mapper(A, a, properties={ - 'bs':relationship(B, secondary=atob, + 'bs':relationship(B, secondary=atob, cascade="all, delete-orphan") }) mapper(B, b) @@ -1776,8 +1776,8 @@ class M2MCascadeTest(fixtures.MappedTest): mapper(A, a, properties={ - 'bs':relationship(B, - secondary=atob, + 'bs':relationship(B, + secondary=atob, cascade="all, delete-orphan", single_parent=True, backref=backref('a', uselist=False)) }) @@ -1801,7 +1801,7 @@ class O2MSelfReferentialDetelOrphanTest(fixtures.MappedTest): @classmethod def define_tables(cls, metadata): Table('node', metadata, - Column('id', Integer, primary_key=True, + Column('id', Integer, primary_key=True, test_needs_autoincrement=True), Column('parent_id', Integer, ForeignKey('node.id')) ) @@ -1817,10 +1817,10 @@ class O2MSelfReferentialDetelOrphanTest(fixtures.MappedTest): node = cls.tables.node mapper(Node, node, properties={ "children":relationship( - Node, - cascade="all, delete-orphan", + Node, + cascade="all, delete-orphan", backref=backref( - "parent", + "parent", remote_side=node.c.id ) ) @@ -1856,12 +1856,12 @@ class NoBackrefCascadeTest(_fixtures.FixtureTest): mapper(Address, addresses) mapper(User, users, properties={ - 'addresses':relationship(Address, backref='user', + 'addresses':relationship(Address, backref='user', cascade_backrefs=False) }) mapper(Dingaling, dingalings, properties={ - 'address' : relationship(Address, backref='dingalings', + 'address' : relationship(Address, backref='dingalings', cascade_backrefs=False) }) @@ -1984,7 +1984,7 @@ class PendingOrphanTestSingleLevel(fixtures.MappedTest): pass def test_pending_standalone_orphan(self): - """Standalone 'orphan' objects can now be persisted, if the underlying + """Standalone 'orphan' objects can now be persisted, if the underlying constraints of the database allow it. This now supports persisting of objects based on foreign key @@ -2021,7 +2021,7 @@ class PendingOrphanTestSingleLevel(fixtures.MappedTest): assert_raises(sa_exc.DBAPIError, s.commit) s.rollback() - # can assign o.user_id by foreign key, + # can assign o.user_id by foreign key, # flush succeeds u = User() s.add(u) @@ -2044,7 +2044,7 @@ class PendingOrphanTestSingleLevel(fixtures.MappedTest): mapper(Address, addresses) mapper(User, users, properties=dict( - addresses=relationship(Address, cascade="all,delete-orphan", + addresses=relationship(Address, cascade="all,delete-orphan", backref="user") )) s = create_session() @@ -2398,14 +2398,14 @@ class DoubleParentM2OOrphanTest(fixtures.MappedTest): class CollectionAssignmentOrphanTest(fixtures.MappedTest): @classmethod def define_tables(cls, metadata): - Table('table_a', metadata, + Table('table_a', metadata, Column('id', Integer, primary_key=True, test_needs_autoincrement=True), Column('name', String(30))) - Table('table_b', metadata, + Table('table_b', metadata, Column('id', Integer, primary_key=True, test_needs_autoincrement=True), - Column('name', String(30)), + Column('name', String(30)), Column('a_id', Integer, ForeignKey('table_a.id'))) def test_basic(self): @@ -2553,7 +2553,7 @@ class O2MConflictTest(fixtures.MappedTest): self.tables.child) mapper(Parent, parent, properties={ - 'child':relationship(Child, uselist=False, + 'child':relationship(Child, uselist=False, cascade="all, delete, delete-orphan") }) mapper(Child, child) @@ -2567,8 +2567,8 @@ class O2MConflictTest(fixtures.MappedTest): self.tables.child) mapper(Parent, parent, properties={ - 'child':relationship(Child, uselist=False, - cascade="all, delete, delete-orphan", + 'child':relationship(Child, uselist=False, + cascade="all, delete, delete-orphan", backref='parent') }) mapper(Child, child) @@ -2583,8 +2583,8 @@ class O2MConflictTest(fixtures.MappedTest): mapper(Parent, parent) mapper(Child, child, properties = { - 'parent' : relationship(Parent, uselist=False, single_parent=True, - backref=backref('child', uselist=False), + 'parent' : relationship(Parent, uselist=False, single_parent=True, + backref=backref('child', uselist=False), cascade="all,delete,delete-orphan") }) self._do_move_test(True) @@ -2598,8 +2598,8 @@ class O2MConflictTest(fixtures.MappedTest): mapper(Parent, parent) mapper(Child, child, properties = { - 'parent' : relationship(Parent, uselist=False, single_parent=True, - backref=backref('child', uselist=True), + 'parent' : relationship(Parent, uselist=False, single_parent=True, + backref=backref('child', uselist=True), cascade="all,delete,delete-orphan") }) self._do_move_test(True) @@ -2616,7 +2616,7 @@ class PartialFlushTest(fixtures.MappedTest): Column("descr", String(50)) ) - Table("noninh_child", metadata, + Table("noninh_child", metadata, Column('id', Integer, primary_key=True, test_needs_autoincrement=True), Column('base_id', Integer, ForeignKey('base.id')) @@ -2654,7 +2654,7 @@ class PartialFlushTest(fixtures.MappedTest): sess.flush([b1]) # c1, c2 get cascaded into the session on o2m. - # not sure if this is how I like this + # not sure if this is how I like this # to work but that's how it works for now. assert c1 in sess and c1 not in sess.new assert c2 in sess and c2 not in sess.new @@ -2701,7 +2701,7 @@ class PartialFlushTest(fixtures.MappedTest): inherits=Base, properties={'parent': relationship( Parent, - backref='children', + backref='children', primaryjoin=inh_child.c.parent_id == parent.c.id )} ) diff --git a/test/orm/test_collection.py b/test/orm/test_collection.py index 42a0ded34..b3de03aae 100644 --- a/test/orm/test_collection.py +++ b/test/orm/test_collection.py @@ -1567,7 +1567,7 @@ class DictHelpersTest(fixtures.MappedTest): ((Foo.id, Foo.bar_id), Foo(id=3, bar_id=12), (3, 12)) ): eq_( - collections.column_mapped_collection(spec)().keyfunc(obj), + collections.column_mapped_collection(spec)().keyfunc(obj), expected ) @@ -1622,11 +1622,11 @@ class ColumnMappedWSerialize(fixtures.MappedTest): @classmethod def define_tables(cls, metadata): - Table('foo', metadata, + Table('foo', metadata, Column('id', Integer(), primary_key=True), Column('b', String(128)) ) - Table('bar', metadata, + Table('bar', metadata, Column('id', Integer(), primary_key=True), Column('foo_id', Integer, ForeignKey('foo.id')), Column('bat_id', Integer), @@ -1673,7 +1673,7 @@ class ColumnMappedWSerialize(fixtures.MappedTest): for spec, obj, expected in specs: coll = collections.column_mapped_collection(spec)() eq_( - coll.keyfunc(obj), + coll.keyfunc(obj), expected ) # ensure we do the right thing with __reduce__ diff --git a/test/orm/test_compile.py b/test/orm/test_compile.py index 68505b0e6..1b2714d70 100644 --- a/test/orm/test_compile.py +++ b/test/orm/test_compile.py @@ -164,7 +164,7 @@ class CompileTest(fixtures.ORMTest): meta = MetaData() a = Table('a', meta, Column('id', Integer, primary_key=True)) - b = Table('b', meta, Column('id', Integer, primary_key=True), + b = Table('b', meta, Column('id', Integer, primary_key=True), Column('a_id', Integer, ForeignKey('a.id'))) class A(object):pass diff --git a/test/orm/test_cycles.py b/test/orm/test_cycles.py index 81f9c1ccd..dce8e04de 100644 --- a/test/orm/test_cycles.py +++ b/test/orm/test_cycles.py @@ -478,7 +478,7 @@ class BiDirectionalOneToManyTest(fixtures.MappedTest): class BiDirectionalOneToManyTest2(fixtures.MappedTest): - """Two mappers with a one-to-many relationship to each other, + """Two mappers with a one-to-many relationship to each other, with a second one-to-many on one of the mappers""" run_define_tables = 'each' @@ -667,8 +667,8 @@ class OneToManyManyToOneTest(fixtures.MappedTest): sess.delete(p) self.assert_sql_execution( - testing.db, - sess.flush, + testing.db, + sess.flush, ExactSQL("UPDATE person SET favorite_ball_id=:favorite_ball_id " "WHERE person.id = :person_id", lambda ctx: {'person_id': p.id, 'favorite_ball_id': None}), @@ -718,7 +718,7 @@ class OneToManyManyToOneTest(fixtures.MappedTest): p2, b1.person ) - # do it the other way + # do it the other way p3.balls.append(b1) sess.commit() eq_( @@ -798,7 +798,7 @@ class OneToManyManyToOneTest(fixtures.MappedTest): sess.delete(p) - self.assert_sql_execution(testing.db, sess.flush, + self.assert_sql_execution(testing.db, sess.flush, CompiledSQL("UPDATE ball SET person_id=:person_id " "WHERE ball.id = :ball_id", lambda ctx:[ @@ -912,7 +912,7 @@ class SelfReferentialPostUpdateTest(fixtures.MappedTest): # pre-trigger lazy loader on 'cats' to make the test easier cats.children self.assert_sql_execution( - testing.db, + testing.db, session.flush, AllOf( CompiledSQL("UPDATE node SET prev_sibling_id=:prev_sibling_id " @@ -935,12 +935,12 @@ class SelfReferentialPostUpdateTest(fixtures.MappedTest): session.delete(root) self.assert_sql_execution( - testing.db, + testing.db, session.flush, CompiledSQL("UPDATE node SET next_sibling_id=:next_sibling_id " - "WHERE node.id = :node_id", + "WHERE node.id = :node_id", lambda ctx: [ - {'node_id': about.id, 'next_sibling_id': None}, + {'node_id': about.id, 'next_sibling_id': None}, {'node_id': stories.id, 'next_sibling_id': None} ] ), @@ -1180,7 +1180,7 @@ class PostUpdateBatchingTest(fixtures.MappedTest): p1.c3 = c31 self.assert_sql_execution( - testing.db, + testing.db, sess.flush, CompiledSQL( "UPDATE parent SET c1_id=:c1_id, c2_id=:c2_id, " @@ -1192,7 +1192,7 @@ class PostUpdateBatchingTest(fixtures.MappedTest): p1.c1 = p1.c2 = p1.c3 = None self.assert_sql_execution( - testing.db, + testing.db, sess.flush, CompiledSQL( "UPDATE parent SET c1_id=:c1_id, c2_id=:c2_id, " diff --git a/test/orm/test_default_strategies.py b/test/orm/test_default_strategies.py index 7dbc9adcb..675cebda8 100644 --- a/test/orm/test_default_strategies.py +++ b/test/orm/test_default_strategies.py @@ -16,11 +16,11 @@ class DefaultStrategyOptionsTest(_fixtures.FixtureTest): # keywords are not part of self.static.user_all_result, so # verify all the item keywords were loaded, with no more sql. # 'any' verifies at least some items have keywords; we build - # a list for any([...]) instead of any(...) to prove we've + # a list for any([...]) instead of any(...) to prove we've # iterated all the items with no sql. f = util.flatten_iterator - assert any([i.keywords for i in - f([o.items for o in f([u.orders for u in users])])]) + assert any([i.keywords for i in + f([o.items for o in f([u.orders for u in users])])]) self.assert_sql_count(testing.db, go, 0) def _assert_addresses_loaded(self, users): @@ -85,13 +85,13 @@ class DefaultStrategyOptionsTest(_fixtures.FixtureTest): mapper(User, users, properties=dict( addresses=relationship(Address, lazy=True, order_by=addresses.c.id), - orders=relationship(Order, + orders=relationship(Order, order_by=orders.c.id))) return create_session() def test_downgrade_baseline(self): - """Mapper strategy defaults load as expected + """Mapper strategy defaults load as expected (compare to rest of DefaultStrategyOptionsTest downgrade tests).""" sess = self._downgrade_fixture() users = [] @@ -107,11 +107,11 @@ class DefaultStrategyOptionsTest(_fixtures.FixtureTest): self._assert_fully_loaded(users) def test_disable_eagerloads(self): - """Mapper eager load strategy defaults can be shut off + """Mapper eager load strategy defaults can be shut off with enable_eagerloads(False).""" - # While this isn't testing a mapper option, it is included - # as baseline reference for how XYZload('*') option + # While this isn't testing a mapper option, it is included + # as baseline reference for how XYZload('*') option # should work, namely, it shouldn't affect later queries # (see other test_select_s) sess = self._downgrade_fixture() @@ -156,8 +156,8 @@ class DefaultStrategyOptionsTest(_fixtures.FixtureTest): sa.orm.subqueryload, '*', User.addresses ) def test_select_with_joinedload(self): - """Mapper load strategy defaults can be downgraded with - lazyload('*') option, while explicit joinedload() option + """Mapper load strategy defaults can be downgraded with + lazyload('*') option, while explicit joinedload() option is still honored""" sess = self._downgrade_fixture() users = [] @@ -181,8 +181,8 @@ class DefaultStrategyOptionsTest(_fixtures.FixtureTest): self.assert_sql_count(testing.db, go, 3) def test_select_with_subqueryload(self): - """Mapper load strategy defaults can be downgraded with - lazyload('*') option, while explicit subqueryload() option + """Mapper load strategy defaults can be downgraded with + lazyload('*') option, while explicit subqueryload() option is still honored""" sess = self._downgrade_fixture() users = [] @@ -215,8 +215,8 @@ class DefaultStrategyOptionsTest(_fixtures.FixtureTest): eq_(users, self.static.user_all_result) def test_noload_with_joinedload(self): - """Mapper load strategy defaults can be downgraded with - noload('*') option, while explicit joinedload() option + """Mapper load strategy defaults can be downgraded with + noload('*') option, while explicit joinedload() option is still honored""" sess = self._downgrade_fixture() users = [] @@ -240,8 +240,8 @@ class DefaultStrategyOptionsTest(_fixtures.FixtureTest): self.assert_sql_count(testing.db, go, 0) def test_noload_with_subqueryload(self): - """Mapper load strategy defaults can be downgraded with - noload('*') option, while explicit subqueryload() option + """Mapper load strategy defaults can be downgraded with + noload('*') option, while explicit subqueryload() option is still honored""" sess = self._downgrade_fixture() users = [] @@ -268,7 +268,7 @@ class DefaultStrategyOptionsTest(_fixtures.FixtureTest): self.assert_sql_count(testing.db, go, 0) def test_joined(self): - """Mapper load strategy defaults can be upgraded with + """Mapper load strategy defaults can be upgraded with joinedload('*') option.""" sess = self._upgrade_fixture() users = [] @@ -285,7 +285,7 @@ class DefaultStrategyOptionsTest(_fixtures.FixtureTest): self._assert_fully_loaded(users) def test_joined_with_lazyload(self): - """Mapper load strategy defaults can be upgraded with + """Mapper load strategy defaults can be upgraded with joinedload('*') option, while explicit lazyload() option is still honored""" sess = self._upgrade_fixture() @@ -316,7 +316,7 @@ class DefaultStrategyOptionsTest(_fixtures.FixtureTest): self.assert_sql_count(testing.db, go, 1) def test_joined_with_subqueryload(self): - """Mapper load strategy defaults can be upgraded with + """Mapper load strategy defaults can be upgraded with joinedload('*') option, while explicit subqueryload() option is still honored""" sess = self._upgrade_fixture() @@ -335,7 +335,7 @@ class DefaultStrategyOptionsTest(_fixtures.FixtureTest): self._assert_fully_loaded(users) def test_subquery(self): - """Mapper load strategy defaults can be upgraded with + """Mapper load strategy defaults can be upgraded with subqueryload('*') option.""" sess = self._upgrade_fixture() users = [] @@ -352,7 +352,7 @@ class DefaultStrategyOptionsTest(_fixtures.FixtureTest): self._assert_fully_loaded(users) def test_subquery_with_lazyload(self): - """Mapper load strategy defaults can be upgraded with + """Mapper load strategy defaults can be upgraded with subqueryload('*') option, while explicit lazyload() option is still honored""" sess = self._upgrade_fixture() @@ -382,8 +382,8 @@ class DefaultStrategyOptionsTest(_fixtures.FixtureTest): self.assert_sql_count(testing.db, go, 1) def test_subquery_with_joinedload(self): - """Mapper load strategy defaults can be upgraded with - subqueryload('*') option, while multiple explicit + """Mapper load strategy defaults can be upgraded with + subqueryload('*') option, while multiple explicit joinedload() options are still honored""" sess = self._upgrade_fixture() users = [] diff --git a/test/orm/test_defaults.py b/test/orm/test_defaults.py index 8063d92b7..a246cddae 100644 --- a/test/orm/test_defaults.py +++ b/test/orm/test_defaults.py @@ -42,7 +42,7 @@ class TriggerDefaultsTest(fixtures.MappedTest): sa.DDL("CREATE TRIGGER dt_ins BEFORE INSERT ON dt " "FOR EACH ROW BEGIN " "SET NEW.col2='ins'; SET NEW.col4='ins'; END", - on=lambda ddl, event, target, bind, **kw: + on=lambda ddl, event, target, bind, **kw: bind.engine.name not in ('oracle', 'mssql', 'sqlite') ), ): @@ -67,7 +67,7 @@ class TriggerDefaultsTest(fixtures.MappedTest): sa.DDL("CREATE TRIGGER dt_up BEFORE UPDATE ON dt " "FOR EACH ROW BEGIN " "SET NEW.col3='up'; SET NEW.col4='up'; END", - on=lambda ddl, event, target, bind, **kw: + on=lambda ddl, event, target, bind, **kw: bind.engine.name not in ('oracle', 'mssql', 'sqlite') ), ): diff --git a/test/orm/test_descriptor.py b/test/orm/test_descriptor.py index c306ebd05..33308880e 100644 --- a/test/orm/test_descriptor.py +++ b/test/orm/test_descriptor.py @@ -9,7 +9,7 @@ from test.lib import fixtures from test.lib.testing import eq_ class TestDescriptor(descriptor_props.DescriptorProperty): - def __init__(self, cls, key, descriptor=None, doc=None, + def __init__(self, cls, key, descriptor=None, doc=None, comparator_factory = None): self.parent = cls.__mapper__ self.key = key diff --git a/test/orm/test_dynamic.py b/test/orm/test_dynamic.py index ba0fa4220..07f01822b 100644 --- a/test/orm/test_dynamic.py +++ b/test/orm/test_dynamic.py @@ -49,7 +49,7 @@ class DynamicTest(_fixtures.FixtureTest, AssertsCompiledSQL): u = q.filter(User.id==7).first() self.assert_compile( - u.addresses.statement, + u.addresses.statement, "SELECT addresses.id, addresses.user_id, addresses.email_address FROM " "addresses WHERE :param_1 = addresses.user_id", use_default_dialect=True @@ -86,7 +86,7 @@ class DynamicTest(_fixtures.FixtureTest, AssertsCompiledSQL): u = sess.query(User).get(8) eq_( list(u.addresses.order_by(desc(Address.email_address))), - [Address(email_address=u'ed@wood.com'), Address(email_address=u'ed@lala.com'), + [Address(email_address=u'ed@wood.com'), Address(email_address=u'ed@lala.com'), Address(email_address=u'ed@bettyboop.com')] ) @@ -209,7 +209,7 @@ class DynamicTest(_fixtures.FixtureTest, AssertsCompiledSQL): assert o1 in i1.orders.all() assert i1 in o1.items.all() - @testing.exclude('mysql', 'between', + @testing.exclude('mysql', 'between', ((5, 1,49), (5, 1, 52)), 'https://bugs.launchpad.net/ubuntu/+source/mysql-5.1/+bug/706988') def test_association_nonaliased(self): @@ -220,8 +220,8 @@ class DynamicTest(_fixtures.FixtureTest, AssertsCompiledSQL): self.classes.Item) mapper(Order, orders, properties={ - 'items':relationship(Item, secondary=order_items, - lazy="dynamic", + 'items':relationship(Item, secondary=order_items, + lazy="dynamic", order_by=order_items.c.item_id) }) mapper(Item, items) @@ -239,7 +239,7 @@ class DynamicTest(_fixtures.FixtureTest, AssertsCompiledSQL): use_default_dialect=True ) - # filter criterion against the secondary table + # filter criterion against the secondary table # works eq_( o.items.filter(order_items.c.item_id==2).all(), @@ -506,7 +506,7 @@ class SessionTest(_fixtures.FixtureTest): sess.flush() sess.commit() u1.addresses.append(Address(email_address='foo@bar.com')) - eq_(u1.addresses.order_by(Address.id).all(), + eq_(u1.addresses.order_by(Address.id).all(), [Address(email_address='lala@hoho.com'), Address(email_address='foo@bar.com')]) sess.rollback() eq_(u1.addresses.all(), [Address(email_address='lala@hoho.com')]) diff --git a/test/orm/test_events.py b/test/orm/test_events.py index 182005d38..33088b582 100644 --- a/test/orm/test_events.py +++ b/test/orm/test_events.py @@ -129,11 +129,11 @@ class MapperEventsTest(_RemoveListeners, _fixtures.FixtureTest): sess.flush() eq_(canary, ['init', 'before_insert', - 'after_insert', 'expire', 'translate_row', + 'after_insert', 'expire', 'translate_row', 'populate_instance', 'refresh', 'append_result', 'translate_row', 'create_instance', 'populate_instance', 'load', 'append_result', - 'before_update', 'after_update', 'before_delete', + 'before_update', 'after_update', 'before_delete', 'after_delete']) def test_merge(self): @@ -226,10 +226,10 @@ class MapperEventsTest(_RemoveListeners, _fixtures.FixtureTest): sess.add(k1) sess.flush() eq_(canary1, - ['init', + ['init', 'before_insert', 'after_insert']) eq_(canary2, - ['init', + ['init', 'before_insert', 'after_insert']) canary1[:]= [] @@ -468,7 +468,7 @@ class SessionEventsTest(_RemoveListeners, _fixtures.FixtureTest): assert my_listener in s.dispatch.before_flush def test_sessionmaker_listen(self): - """test that listen can be applied to individual + """test that listen can be applied to individual scoped_session() classes.""" def my_listener_one(*arg, **kw): @@ -568,16 +568,16 @@ class SessionEventsTest(_RemoveListeners, _fixtures.FixtureTest): mapper(User, users) - sess, canary = self._listener_fixture(autoflush=False, + sess, canary = self._listener_fixture(autoflush=False, autocommit=True, expire_on_commit=False) u = User(name='u1') sess.add(u) sess.flush() eq_( - canary, + canary, [ 'before_attach', 'after_attach', 'before_flush', 'after_begin', - 'after_flush', 'after_flush_postexec', + 'after_flush', 'after_flush_postexec', 'before_commit', 'after_commit',] ) @@ -597,10 +597,10 @@ class SessionEventsTest(_RemoveListeners, _fixtures.FixtureTest): sess.commit ) sess.rollback() - eq_(canary, ['before_attach', 'after_attach', 'before_commit', 'before_flush', - 'after_begin', 'after_flush', 'after_flush_postexec', - 'after_commit', 'before_attach', 'after_attach', 'before_commit', - 'before_flush', 'after_begin', 'after_rollback', + eq_(canary, ['before_attach', 'after_attach', 'before_commit', 'before_flush', + 'after_begin', 'after_flush', 'after_flush_postexec', + 'after_commit', 'before_attach', 'after_attach', 'before_commit', + 'before_flush', 'after_begin', 'after_rollback', 'after_soft_rollback', 'after_soft_rollback']) def test_can_use_session_in_outer_rollback_hook(self): @@ -760,7 +760,7 @@ class SessionEventsTest(_RemoveListeners, _fixtures.FixtureTest): u = User(name='u1') sess.add(u) sess.flush() - eq_(sess.query(User).order_by(User.name).all(), + eq_(sess.query(User).order_by(User.name).all(), [ User(name='another u1'), User(name='u1') @@ -768,7 +768,7 @@ class SessionEventsTest(_RemoveListeners, _fixtures.FixtureTest): ) sess.flush() - eq_(sess.query(User).order_by(User.name).all(), + eq_(sess.query(User).order_by(User.name).all(), [ User(name='another u1'), User(name='u1') @@ -777,7 +777,7 @@ class SessionEventsTest(_RemoveListeners, _fixtures.FixtureTest): u.name='u2' sess.flush() - eq_(sess.query(User).order_by(User.name).all(), + eq_(sess.query(User).order_by(User.name).all(), [ User(name='another u1'), User(name='another u2'), @@ -787,7 +787,7 @@ class SessionEventsTest(_RemoveListeners, _fixtures.FixtureTest): sess.delete(u) sess.flush() - eq_(sess.query(User).order_by(User.name).all(), + eq_(sess.query(User).order_by(User.name).all(), [ User(name='another u1'), ] @@ -808,14 +808,14 @@ class SessionEventsTest(_RemoveListeners, _fixtures.FixtureTest): u = User(name='u1') sess.add(u) sess.flush() - eq_(sess.query(User).order_by(User.name).all(), + eq_(sess.query(User).order_by(User.name).all(), [User(name='u1')] ) sess.add(User(name='u2')) sess.flush() sess.expunge_all() - eq_(sess.query(User).order_by(User.name).all(), + eq_(sess.query(User).order_by(User.name).all(), [ User(name='u1 modified'), User(name='u2') @@ -825,7 +825,7 @@ class SessionEventsTest(_RemoveListeners, _fixtures.FixtureTest): class MapperExtensionTest(_fixtures.FixtureTest): - """Superseded by MapperEventsTest - test backwards + """Superseded by MapperEventsTest - test backwards compatibility of MapperExtension.""" run_inserts = None @@ -977,10 +977,10 @@ class MapperExtensionTest(_fixtures.FixtureTest): sess.add(k1) sess.flush() eq_(methods1, - ['instrument_class', 'init_instance', + ['instrument_class', 'init_instance', 'before_insert', 'after_insert']) eq_(methods2, - ['instrument_class', 'init_instance', + ['instrument_class', 'init_instance', 'before_insert', 'after_insert']) del methods1[:] @@ -1060,7 +1060,7 @@ class MapperExtensionTest(_fixtures.FixtureTest): class AttributeExtensionTest(fixtures.MappedTest): @classmethod def define_tables(cls, metadata): - Table('t1', + Table('t1', metadata, Column('id', Integer, primary_key=True), Column('type', String(40)), @@ -1113,7 +1113,7 @@ class AttributeExtensionTest(fixtures.MappedTest): eq_(b1.data, 'ex1b2') eq_(c1.data, 'ex2c2') - eq_(ext_msg, ["Ex1 'a1'", "Ex1 'b1'", "Ex2 'c1'", + eq_(ext_msg, ["Ex1 'a1'", "Ex1 'b1'", "Ex2 'c1'", "Ex1 'a2'", "Ex1 'b2'", "Ex2 'c2'"]) diff --git a/test/orm/test_expire.py b/test/orm/test_expire.py index c73306665..16ca8b0ba 100644 --- a/test/orm/test_expire.py +++ b/test/orm/test_expire.py @@ -67,7 +67,7 @@ class ExpireTest(_fixtures.FixtureTest): u = s.query(User).get(7) s.expunge_all() - assert_raises_message(sa_exc.InvalidRequestError, + assert_raises_message(sa_exc.InvalidRequestError, r"is not persistent within this Session", s.expire, u) def test_get_refreshes(self): @@ -138,12 +138,12 @@ class ExpireTest(_fixtures.FixtureTest): s.rollback() assert u in s - # but now its back, rollback has occurred, the + # but now its back, rollback has occurred, the # _remove_newly_deleted is reverted eq_(u.name, 'chuck') def test_deferred(self): - """test that unloaded, deferred attributes aren't included in the + """test that unloaded, deferred attributes aren't included in the expiry list.""" Order, orders = self.classes.Order, self.tables.orders @@ -185,7 +185,7 @@ class ExpireTest(_fixtures.FixtureTest): self.classes.User) mapper(User, users, properties={ - 'addresses':relationship(Address, + 'addresses':relationship(Address, order_by=addresses.c.email_address) }) mapper(Address, addresses) @@ -193,21 +193,21 @@ class ExpireTest(_fixtures.FixtureTest): u = s.query(User).get(8) adlist = u.addresses eq_(adlist, [ - Address(email_address='ed@bettyboop.com'), + Address(email_address='ed@bettyboop.com'), Address(email_address='ed@lala.com'), - Address(email_address='ed@wood.com'), + Address(email_address='ed@wood.com'), ]) a1 = u.addresses[2] a1.email_address = 'aaaaa' s.expire(u, ['addresses']) eq_(u.addresses, [ - Address(email_address='aaaaa'), - Address(email_address='ed@bettyboop.com'), + Address(email_address='aaaaa'), + Address(email_address='ed@bettyboop.com'), Address(email_address='ed@lala.com'), ]) def test_refresh_collection_exception(self): - """test graceful failure for currently unsupported + """test graceful failure for currently unsupported immediate refresh of a collection""" users, Address, addresses, User = (self.tables.users, @@ -222,12 +222,12 @@ class ExpireTest(_fixtures.FixtureTest): mapper(Address, addresses) s = create_session(autoflush=True, autocommit=False) u = s.query(User).get(8) - assert_raises_message(sa_exc.InvalidRequestError, - "properties specified for refresh", + assert_raises_message(sa_exc.InvalidRequestError, + "properties specified for refresh", s.refresh, u, ['addresses']) # in contrast to a regular query with no columns - assert_raises_message(sa_exc.InvalidRequestError, + assert_raises_message(sa_exc.InvalidRequestError, "no columns with which to SELECT", s.query().all) def test_refresh_cancels_expire(self): @@ -862,7 +862,7 @@ class ExpireTest(_fixtures.FixtureTest): self.classes.User) mapper(User, users, properties={ - 'addresses':relationship(Address, backref='user', lazy='joined', + 'addresses':relationship(Address, backref='user', lazy='joined', order_by=addresses.c.id), }) mapper(Address, addresses) @@ -941,7 +941,7 @@ class ExpireTest(_fixtures.FixtureTest): u1 = sess.query(User).options(undefer(User.name)).first() assert 'name' not in attributes.instance_state(u1).callables - # mass expire, the attribute was loaded, + # mass expire, the attribute was loaded, # the attribute gets the callable sess.expire(u1) assert isinstance( @@ -954,7 +954,7 @@ class ExpireTest(_fixtures.FixtureTest): assert 'name' not in attributes.instance_state(u1).callables # mass expire, attribute was loaded but then deleted, - # the callable goes away - the state wants to flip + # the callable goes away - the state wants to flip # it back to its "deferred" loader. sess.expunge_all() u1 = sess.query(User).options(undefer(User.name)).first() @@ -1164,7 +1164,7 @@ class ExpiredPendingTest(_fixtures.FixtureTest): # which attach to u1 will expect to be "pending" sess.expire(u1, ['addresses']) - # attach an Address. now its "pending" + # attach an Address. now its "pending" # in user.addresses a2 = Address(email_address='a2') a2.user = u1 diff --git a/test/orm/test_hasparent.py b/test/orm/test_hasparent.py index 3940c03da..73b9fb3b2 100644 --- a/test/orm/test_hasparent.py +++ b/test/orm/test_hasparent.py @@ -19,7 +19,7 @@ class ParentRemovalTest(fixtures.MappedTest): """Test that the 'hasparent' flag gets flipped to False only if we're sure this object is the real parent. - In ambiguous cases a stale data exception is + In ambiguous cases a stale data exception is raised. """ @@ -120,8 +120,8 @@ class ParentRemovalTest(fixtures.MappedTest): u1 = s.query(User).first() - # primary key change. now we - # can't rely on state.key as the + # primary key change. now we + # can't rely on state.key as the # identifier. u1.id = 5 a1.user_id = 5 @@ -146,7 +146,7 @@ class ParentRemovalTest(fixtures.MappedTest): def test_stale_state_negative_child_expired(self): """illustrate the current behavior of expiration on the child. - + there's some uncertainty here in how this use case should work. diff --git a/test/orm/test_joins.py b/test/orm/test_joins.py index 6c43a2f39..086897186 100644 --- a/test/orm/test_joins.py +++ b/test/orm/test_joins.py @@ -57,7 +57,7 @@ class QueryTest(_fixtures.FixtureTest): mapper(Keyword, keywords) mapper(Node, nodes, properties={ - 'children':relationship(Node, + 'children':relationship(Node, backref=backref('parent', remote_side=[nodes.c.id]) ) }) @@ -140,17 +140,17 @@ class InheritedJoinTest(fixtures.MappedTest, AssertsCompiledSQL): mapper(Machine, machines) - mapper(Person, people, - polymorphic_on=people.c.type, - polymorphic_identity='person', - order_by=people.c.person_id, + mapper(Person, people, + polymorphic_on=people.c.type, + polymorphic_identity='person', + order_by=people.c.person_id, properties={ 'paperwork':relationship(Paperwork, order_by=paperwork.c.paperwork_id) }) mapper(Engineer, engineers, inherits=Person, polymorphic_identity='engineer', properties={ 'machines':relationship(Machine, order_by=machines.c.machine_id) }) - mapper(Manager, managers, + mapper(Manager, managers, inherits=Person, polymorphic_identity='manager') mapper(Boss, boss, inherits=Manager, polymorphic_identity='boss') mapper(Paperwork, paperwork) @@ -405,7 +405,7 @@ class JoinTest(QueryTest, AssertsCompiledSQL): ) def test_multi_tuple_form(self): - """test the 'tuple' form of join, now superseded + """test the 'tuple' form of join, now superseded by the two-element join() form. Not deprecating this style as of yet. @@ -432,7 +432,7 @@ class JoinTest(QueryTest, AssertsCompiledSQL): self.assert_compile( sess.query(User).join( - (Order, User.id==Order.user_id), + (Order, User.id==Order.user_id), (Item, Order.items)), "SELECT users.id AS users_id, users.name AS users_name " "FROM users JOIN orders ON users.id = orders.user_id " @@ -617,8 +617,8 @@ class JoinTest(QueryTest, AssertsCompiledSQL): for oalias,ialias in [(True, True), (False, False), (True, False), (False, True)]: eq_( sess.query(User).join('orders', aliased=oalias).\ - join('items', - from_joinpoint=True, + join('items', + from_joinpoint=True, aliased=ialias).\ filter(Item.description == 'item 4').all(), [User(name='jack')] @@ -628,7 +628,7 @@ class JoinTest(QueryTest, AssertsCompiledSQL): eq_( sess.query(User).join('orders', aliased=oalias).\ filter(Order.user_id==9).\ - join('items', from_joinpoint=True, + join('items', from_joinpoint=True, aliased=ialias).\ filter(Item.description=='item 4').all(), [] @@ -637,7 +637,7 @@ class JoinTest(QueryTest, AssertsCompiledSQL): orderalias = aliased(Order) itemalias = aliased(Item) eq_( - sess.query(User).join(orderalias, 'orders'). + sess.query(User).join(orderalias, 'orders'). join(itemalias, 'items', from_joinpoint=True). filter(itemalias.description == 'item 4').all(), [User(name='jack')] @@ -692,7 +692,7 @@ class JoinTest(QueryTest, AssertsCompiledSQL): sess.query(User).join, Address, Address.user, ) - # but this one would silently fail + # but this one would silently fail adalias = aliased(Address) assert_raises( sa_exc.InvalidRequestError, @@ -848,7 +848,7 @@ class JoinTest(QueryTest, AssertsCompiledSQL): # be using the aliased flag in this way. self.assert_compile( sess.query(User).join(User.orders, aliased=True). - join(Item, + join(Item, and_(Order.id==order_items.c.order_id, order_items.c.item_id==Item.id), from_joinpoint=True, aliased=True ), @@ -862,7 +862,7 @@ class JoinTest(QueryTest, AssertsCompiledSQL): oalias = orders.select() self.assert_compile( sess.query(User).join(oalias, User.orders). - join(Item, + join(Item, and_(Order.id==order_items.c.order_id, order_items.c.item_id==Item.id), from_joinpoint=True ), @@ -938,7 +938,7 @@ class JoinTest(QueryTest, AssertsCompiledSQL): ) eq_( - sess.query(User.name).join(Order, User.id==Order.user_id). + sess.query(User.name).join(Order, User.id==Order.user_id). join(order_items, Order.id==order_items.c.order_id). join(Item, order_items.c.item_id==Item.id). filter(Item.description == 'item 4').all(), @@ -1063,8 +1063,8 @@ class JoinTest(QueryTest, AssertsCompiledSQL): sess.query(OrderAlias).join('items').filter_by(description='item 3').\ order_by(OrderAlias.id).all(), [ - Order(address_id=1,description=u'order 1',isopen=0,user_id=7,id=1), - Order(address_id=4,description=u'order 2',isopen=0,user_id=9,id=2), + Order(address_id=1,description=u'order 1',isopen=0,user_id=7,id=1), + Order(address_id=4,description=u'order 2',isopen=0,user_id=9,id=2), Order(address_id=1,description=u'order 3',isopen=1,user_id=7,id=3) ] ) @@ -1076,8 +1076,8 @@ class JoinTest(QueryTest, AssertsCompiledSQL): filter_by(description='item 3').\ order_by(User.id, OrderAlias.id).all(), [ - (User(name=u'jack',id=7), Order(address_id=1,description=u'order 1',isopen=0,user_id=7,id=1), u'item 3'), - (User(name=u'jack',id=7), Order(address_id=1,description=u'order 3',isopen=1,user_id=7,id=3), u'item 3'), + (User(name=u'jack',id=7), Order(address_id=1,description=u'order 1',isopen=0,user_id=7,id=1), u'item 3'), + (User(name=u'jack',id=7), Order(address_id=1,description=u'order 3',isopen=1,user_id=7,id=3), u'item 3'), (User(name=u'fred',id=9), Order(address_id=4,description=u'order 2',isopen=0,user_id=9,id=2), u'item 3') ] ) @@ -1112,7 +1112,7 @@ class JoinTest(QueryTest, AssertsCompiledSQL): IAlias = aliased(Item) q = sess.query(Order, IAlias).select_from(join(Order, IAlias, 'items')).filter(IAlias.description=='item 3') l = q.all() - eq_(l, + eq_(l, [ (order1, item3), (order2, item3), @@ -1235,10 +1235,10 @@ class JoinTest(QueryTest, AssertsCompiledSQL): eq_( sess.query(User, ualias).filter(User.id > ualias.id).order_by(desc(ualias.id), User.name).all(), [ - (User(id=10,name=u'chuck'), User(id=9,name=u'fred')), - (User(id=10,name=u'chuck'), User(id=8,name=u'ed')), - (User(id=9,name=u'fred'), User(id=8,name=u'ed')), - (User(id=10,name=u'chuck'), User(id=7,name=u'jack')), + (User(id=10,name=u'chuck'), User(id=9,name=u'fred')), + (User(id=10,name=u'chuck'), User(id=8,name=u'ed')), + (User(id=9,name=u'fred'), User(id=8,name=u'ed')), + (User(id=10,name=u'chuck'), User(id=7,name=u'jack')), (User(id=8,name=u'ed'), User(id=7,name=u'jack')), (User(id=9,name=u'fred'), User(id=7,name=u'jack')) ] @@ -1338,7 +1338,7 @@ class JoinFromSelectableTest(fixtures.MappedTest, AssertsCompiledSQL): @classmethod def define_tables(cls, metadata): - Table('table1', metadata, + Table('table1', metadata, Column('id', Integer, primary_key=True) ) Table('table2', metadata, @@ -1563,9 +1563,9 @@ class SelfRefMixedTest(fixtures.MappedTest, AssertsCompiledSQL): backref=backref('parent', remote_side=[nodes.c.id]) ), 'subs' : relationship(Sub), - 'assoc':relationship(Node, - secondary=assoc_table, - primaryjoin=nodes.c.id==assoc_table.c.left_id, + 'assoc':relationship(Node, + secondary=assoc_table, + primaryjoin=nodes.c.id==assoc_table.c.left_id, secondaryjoin=nodes.c.id==assoc_table.c.right_id) }) mapper(Sub, sub_table) @@ -1618,13 +1618,13 @@ class CreateJoinsTest(fixtures.ORMTest, AssertsCompiledSQL): def _inherits_fixture(self): m = MetaData() base = Table('base', m, Column('id', Integer, primary_key=True)) - a = Table('a', m, + a = Table('a', m, Column('id', Integer, ForeignKey('base.id'), primary_key=True), Column('b_id', Integer, ForeignKey('b.id'))) - b = Table('b', m, + b = Table('b', m, Column('id', Integer, ForeignKey('base.id'), primary_key=True), Column('c_id', Integer, ForeignKey('c.id'))) - c = Table('c', m, + c = Table('c', m, Column('id', Integer, ForeignKey('base.id'), primary_key=True)) class Base(object): pass @@ -1809,7 +1809,7 @@ class SelfReferentialTest(fixtures.MappedTest, AssertsCompiledSQL): filter(Node.data=='n122').filter(parent.data=='n12').\ filter(grandparent.data=='n1').from_self().limit(1) - # parent, grandparent *are* inside the from_self(), so they + # parent, grandparent *are* inside the from_self(), so they # should get aliased to the outside. self.assert_compile( q, @@ -1983,7 +1983,7 @@ class SelfReferentialTest(fixtures.MappedTest, AssertsCompiledSQL): sess = create_session() eq_(sess.query(Node).filter(Node.children.any(Node.data=='n1')).all(), []) eq_(sess.query(Node).filter(Node.children.any(Node.data=='n12')).all(), [Node(data='n1')]) - eq_(sess.query(Node).filter(~Node.children.any()).order_by(Node.id).all(), + eq_(sess.query(Node).filter(~Node.children.any()).order_by(Node.id).all(), [Node(data='n11'), Node(data='n13'),Node(data='n121'),Node(data='n122'),Node(data='n123'),]) def test_has(self): @@ -1991,7 +1991,7 @@ class SelfReferentialTest(fixtures.MappedTest, AssertsCompiledSQL): sess = create_session() - eq_(sess.query(Node).filter(Node.parent.has(Node.data=='n12')).order_by(Node.id).all(), + eq_(sess.query(Node).filter(Node.parent.has(Node.data=='n12')).order_by(Node.id).all(), [Node(data='n121'),Node(data='n122'),Node(data='n123')]) eq_(sess.query(Node).filter(Node.parent.has(Node.data=='n122')).all(), []) eq_(sess.query(Node).filter(~Node.parent.has()).all(), [Node(data='n1')]) diff --git a/test/orm/test_lazy_relations.py b/test/orm/test_lazy_relations.py index dd50dfa3d..297d027f5 100644 --- a/test/orm/test_lazy_relations.py +++ b/test/orm/test_lazy_relations.py @@ -264,7 +264,7 @@ class LazyTest(_fixtures.FixtureTest): User(id=8, address=Address(id=3)), User(id=9, address=None), User(id=10, address=None), - ], + ], list(q) ) @@ -397,7 +397,7 @@ class LazyTest(_fixtures.FixtureTest): SomeDBInteger, ]: m = sa.MetaData() - users = Table('users', m, + users = Table('users', m, Column('id', Integer, primary_key=True, test_needs_autoincrement=True), Column('name', String(30), nullable=False), ) @@ -486,7 +486,7 @@ class LazyTest(_fixtures.FixtureTest): self.assert_sql_count(testing.db, go, 1) class GetterStateTest(_fixtures.FixtureTest): - """test lazyloader on non-existent attribute returns + """test lazyloader on non-existent attribute returns expected attribute symbols, maintain expected state""" run_inserts = None @@ -516,8 +516,8 @@ class GetterStateTest(_fixtures.FixtureTest): User, Address, sess, a1 = self._u_ad_fixture(False) eq_( Address.user.impl.get( - attributes.instance_state(a1), - attributes.instance_dict(a1), + attributes.instance_state(a1), + attributes.instance_dict(a1), passive=attributes.PASSIVE_RETURN_NEVER_SET), attributes.NEVER_SET ) @@ -528,8 +528,8 @@ class GetterStateTest(_fixtures.FixtureTest): User, Address, sess, a1 = self._u_ad_fixture(False) eq_( Address.user.impl.get_history( - attributes.instance_state(a1), - attributes.instance_dict(a1), + attributes.instance_state(a1), + attributes.instance_dict(a1), passive=attributes.PASSIVE_RETURN_NEVER_SET), ((), (), ()) ) @@ -540,8 +540,8 @@ class GetterStateTest(_fixtures.FixtureTest): User, Address, sess, a1 = self._u_ad_fixture(False) eq_( Address.user.impl.get( - attributes.instance_state(a1), - attributes.instance_dict(a1), + attributes.instance_state(a1), + attributes.instance_dict(a1), passive=attributes.PASSIVE_NO_INITIALIZE), attributes.PASSIVE_NO_RESULT ) @@ -552,8 +552,8 @@ class GetterStateTest(_fixtures.FixtureTest): User, Address, sess, a1 = self._u_ad_fixture(False) eq_( Address.user.impl.get_history( - attributes.instance_state(a1), - attributes.instance_dict(a1), + attributes.instance_state(a1), + attributes.instance_dict(a1), passive=attributes.PASSIVE_NO_INITIALIZE), attributes.HISTORY_BLANK ) @@ -564,8 +564,8 @@ class GetterStateTest(_fixtures.FixtureTest): User, Address, sess, a1 = self._u_ad_fixture(True) eq_( Address.user.impl.get( - attributes.instance_state(a1), - attributes.instance_dict(a1), + attributes.instance_state(a1), + attributes.instance_dict(a1), passive=attributes.PASSIVE_NO_INITIALIZE), attributes.PASSIVE_NO_RESULT ) @@ -576,8 +576,8 @@ class GetterStateTest(_fixtures.FixtureTest): User, Address, sess, a1 = self._u_ad_fixture(True) eq_( Address.user.impl.get_history( - attributes.instance_state(a1), - attributes.instance_dict(a1), + attributes.instance_state(a1), + attributes.instance_dict(a1), passive=attributes.PASSIVE_NO_INITIALIZE), attributes.HISTORY_BLANK ) @@ -588,8 +588,8 @@ class GetterStateTest(_fixtures.FixtureTest): User, Address, sess, a1 = self._u_ad_fixture(True) eq_( Address.user.impl.get( - attributes.instance_state(a1), - attributes.instance_dict(a1), + attributes.instance_state(a1), + attributes.instance_dict(a1), passive=attributes.PASSIVE_RETURN_NEVER_SET), User(name='ed') ) @@ -598,8 +598,8 @@ class GetterStateTest(_fixtures.FixtureTest): User, Address, sess, a1 = self._u_ad_fixture(True) eq_( Address.user.impl.get_history( - attributes.instance_state(a1), - attributes.instance_dict(a1), + attributes.instance_state(a1), + attributes.instance_dict(a1), passive=attributes.PASSIVE_RETURN_NEVER_SET), ((), [User(name='ed'), ], ()) ) diff --git a/test/orm/test_load_on_fks.py b/test/orm/test_load_on_fks.py index be355808e..05b78ccb8 100644 --- a/test/orm/test_load_on_fks.py +++ b/test/orm/test_load_on_fks.py @@ -251,7 +251,7 @@ class LoadOnFKsTest(AssertsExecutionResults, fixtures.TestBase): #if manualflush and (not loadrel or fake_autoexpire): # # a flush occurs, we get p2 # assert c1.parent is p2 - #elif not loadrel and not loadfk: + #elif not loadrel and not loadfk: # # problematically - we get None since committed state # # is empty when c1.parent_id was mutated, since we want # # to save on selects. this is diff --git a/test/orm/test_lockmode.py b/test/orm/test_lockmode.py index 9fc2ea074..b2bc60865 100644 --- a/test/orm/test_lockmode.py +++ b/test/orm/test_lockmode.py @@ -43,8 +43,8 @@ class LockModeTest(_fixtures.FixtureTest, AssertsCompiledSQL): User = self.classes.User sess = Session() assert_raises_message( - Exception, "Unknown lockmode 'unknown_mode'", - self.assert_compile, + Exception, "Unknown lockmode 'unknown_mode'", + self.assert_compile, sess.query(User.id).with_lockmode('unknown_mode'), None, dialect=default.DefaultDialect() ) diff --git a/test/orm/test_manytomany.py b/test/orm/test_manytomany.py index db7f63565..ed9075833 100644 --- a/test/orm/test_manytomany.py +++ b/test/orm/test_manytomany.py @@ -107,7 +107,7 @@ class M2MTest(fixtures.MappedTest): mapper(Place, place, properties={ 'places': relationship( Place, - secondary=place_place, + secondary=place_place, primaryjoin=place.c.place_id==place_place.c.pl1_id, secondaryjoin=place.c.place_id==place_place.c.pl2_id, order_by=place_place.c.pl2_id @@ -162,7 +162,7 @@ class M2MTest(fixtures.MappedTest): mapper(Place, place, properties={ 'child_places': relationship( Place, - secondary=place_place, + secondary=place_place, primaryjoin=place.c.place_id==place_place.c.pl1_id, secondaryjoin=place.c.place_id==place_place.c.pl2_id, order_by=place_place.c.pl2_id, @@ -268,7 +268,7 @@ class M2MTest(fixtures.MappedTest): self.tables.transition) mapper(Place, place, properties={ - 'transitions':relationship(Transition, secondary=place_input, + 'transitions':relationship(Transition, secondary=place_input, passive_updates=False) }) mapper(Transition, transition) diff --git a/test/orm/test_merge.py b/test/orm/test_merge.py index c45a0e9da..47203b874 100644 --- a/test/orm/test_merge.py +++ b/test/orm/test_merge.py @@ -48,7 +48,7 @@ class MergeTest(_fixtures.FixtureTest): eq_(sess.query(User).first(), User(id=7, name='fred')) def test_transient_to_pending_no_pk(self): - """test that a transient object with no PK attribute + """test that a transient object with no PK attribute doesn't trigger a needless load.""" User, users = self.classes.User, self.tables.users @@ -219,7 +219,7 @@ class MergeTest(_fixtures.FixtureTest): Address(id=3, email_address='fred3')]))) def test_unsaved_cascade(self): - """Merge of a transient entity with two child transient + """Merge of a transient entity with two child transient entities, with a bidirectional relationship.""" users, Address, addresses, User = (self.tables.users, @@ -271,7 +271,7 @@ class MergeTest(_fixtures.FixtureTest): sess = create_session() # merge empty stuff. goes in as NULL. - # not sure what this was originally trying to + # not sure what this was originally trying to # test. u1 = sess.merge(User(id=1)) sess.flush() @@ -309,7 +309,7 @@ class MergeTest(_fixtures.FixtureTest): sess.flush() # blow it away from u5, but don't - # mark as expired. so it would just + # mark as expired. so it would just # be blank. del u5.data @@ -349,7 +349,7 @@ class MergeTest(_fixtures.FixtureTest): assert u1.addresses.keys() == ['foo@bar.com'] def test_attribute_cascade(self): - """Merge of a persistent entity with two child + """Merge of a persistent entity with two child persistent entities.""" users, Address, addresses, User = (self.tables.users, @@ -359,7 +359,7 @@ class MergeTest(_fixtures.FixtureTest): mapper(User, users, properties={ - 'addresses':relationship(mapper(Address, addresses), + 'addresses':relationship(mapper(Address, addresses), backref='user') }) load = self.load_tracker(User) @@ -557,7 +557,7 @@ class MergeTest(_fixtures.FixtureTest): sess2 = create_session() a2 = sess2.merge(a1) eq_( - attributes.get_history(a2, 'user'), + attributes.get_history(a2, 'user'), ([u2], (), ()) ) assert a2 in sess2.dirty @@ -567,7 +567,7 @@ class MergeTest(_fixtures.FixtureTest): sess2 = create_session() a2 = sess2.merge(a1, load=False) eq_( - attributes.get_history(a2, 'user'), + attributes.get_history(a2, 'user'), ((), [u1], ()) ) assert a2 not in sess2.dirty @@ -581,7 +581,7 @@ class MergeTest(_fixtures.FixtureTest): mapper(Order, orders, properties={ - 'items':relationship(mapper(Item, items), + 'items':relationship(mapper(Item, items), secondary=order_items)}) load = self.load_tracker(Order) @@ -672,7 +672,7 @@ class MergeTest(_fixtures.FixtureTest): uselist = False, backref='user') }) sess = sessionmaker()() - u = User(id=7, name="fred", + u = User(id=7, name="fred", address=Address(id=1, email_address='foo@bar.com')) sess.add(u) sess.commit() @@ -696,12 +696,12 @@ class MergeTest(_fixtures.FixtureTest): sess = create_session() u = User() - assert_raises_message(sa.exc.InvalidRequestError, - "load=False option does not support", + assert_raises_message(sa.exc.InvalidRequestError, + "load=False option does not support", sess.merge, u, load=False) def test_no_load_with_backrefs(self): - """load=False populates relationships in both + """load=False populates relationships in both directions without requiring a load""" users, Address, addresses, User = (self.tables.users, @@ -710,7 +710,7 @@ class MergeTest(_fixtures.FixtureTest): self.classes.User) mapper(User, users, properties={ - 'addresses':relationship(mapper(Address, addresses), + 'addresses':relationship(mapper(Address, addresses), backref='user') }) @@ -740,7 +740,7 @@ class MergeTest(_fixtures.FixtureTest): def test_dontload_with_eager(self): """ - + This test illustrates that with load=False, we can't just copy the committed_state of the merged instance over; since it references collection objects which themselves are to be merged. @@ -749,7 +749,7 @@ class MergeTest(_fixtures.FixtureTest): moment I'd rather not support this use case; if you are merging with load=False, you're typically dealing with caching and the merged objects shouldnt be 'dirty'. - + """ users, Address, addresses, User = (self.tables.users, @@ -852,7 +852,7 @@ class MergeTest(_fixtures.FixtureTest): def test_no_load_preserves_parents(self): """Merge with load=False does not trigger a 'delete-orphan' operation. - + merge with load=False sets attributes without using events. this means the 'hasparent' flag is not propagated to the newly merged instance. in fact this works out OK, because the @@ -861,7 +861,7 @@ class MergeTest(_fixtures.FixtureTest): this collection when _is_orphan() is called, it does not count as an orphan (i.e. this is the 'optimistic' logic in mapper._is_orphan().) - + """ users, Address, addresses, User = (self.tables.users, @@ -871,7 +871,7 @@ class MergeTest(_fixtures.FixtureTest): mapper(User, users, properties={ 'addresses':relationship(mapper(Address, addresses), - backref='user', + backref='user', cascade="all, delete-orphan")}) sess = create_session() u = User() @@ -972,7 +972,7 @@ class MergeTest(_fixtures.FixtureTest): a1 = Address(user=s.merge(User(id=1, name='ed')), email_address='x') before_id = id(a1.user) - a2 = Address(user=s.merge(User(id=1, name='jack')), + a2 = Address(user=s.merge(User(id=1, name='jack')), email_address='x') after_id = id(a1.user) other_id = id(a2.user) @@ -991,7 +991,7 @@ class MergeTest(_fixtures.FixtureTest): m = mapper(User, users, properties={ 'addresses':relationship(mapper(Address, addresses), backref='user')}) - user = User(id=8, name='fred', + user = User(id=8, name='fred', addresses=[Address(email_address='user')]) merged_user = sess.merge(user) assert merged_user in sess.new @@ -1104,7 +1104,7 @@ class MergeTest(_fixtures.FixtureTest): class M2ONoUseGetLoadingTest(fixtures.MappedTest): - """Merge a one-to-many. The many-to-one on the other side is set up + """Merge a one-to-many. The many-to-one on the other side is set up so that use_get is False. See if skipping the "m2o" merge vs. doing it saves on SQL calls. @@ -1113,12 +1113,12 @@ class M2ONoUseGetLoadingTest(fixtures.MappedTest): @classmethod def define_tables(cls, metadata): Table('user', metadata, - Column('id', Integer, primary_key=True, + Column('id', Integer, primary_key=True, test_needs_autoincrement=True), Column('name', String(50)), ) Table('address', metadata, - Column('id', Integer, primary_key=True, + Column('id', Integer, primary_key=True, test_needs_autoincrement=True), Column('user_id', Integer, ForeignKey('user.id')), Column('email', String(50)), @@ -1137,11 +1137,11 @@ class M2ONoUseGetLoadingTest(fixtures.MappedTest): user, address = cls.tables.user, cls.tables.address mapper(User, user, properties={ 'addresses':relationship(Address, backref= - backref('user', + backref('user', # needlessly complex primaryjoin so that the # use_get flag is False primaryjoin=and_( - user.c.id==address.c.user_id, + user.c.id==address.c.user_id, user.c.id==user.c.id ) ) @@ -1156,20 +1156,20 @@ class M2ONoUseGetLoadingTest(fixtures.MappedTest): User, Address = cls.classes.User, cls.classes.Address s = Session() s.add_all([ - User(id=1, name='u1', addresses=[Address(id=1, email='a1'), + User(id=1, name='u1', addresses=[Address(id=1, email='a1'), Address(id=2, email='a2')]) ]) s.commit() # "persistent" - we get at an Address that was already present. - # With the "skip bidirectional" check removed, the "set" emits SQL + # With the "skip bidirectional" check removed, the "set" emits SQL # for the "previous" version in any case, # address.user_id is 1, you get a load. def test_persistent_access_none(self): User, Address = self.classes.User, self.classes.Address s = Session() def go(): - u1 = User(id=1, + u1 = User(id=1, addresses =[Address(id=1), Address(id=2)] ) u2 = s.merge(u1) @@ -1179,7 +1179,7 @@ class M2ONoUseGetLoadingTest(fixtures.MappedTest): User, Address = self.classes.User, self.classes.Address s = Session() def go(): - u1 = User(id=1, + u1 = User(id=1, addresses =[Address(id=1), Address(id=2)] ) u2 = s.merge(u1) @@ -1191,7 +1191,7 @@ class M2ONoUseGetLoadingTest(fixtures.MappedTest): User, Address = self.classes.User, self.classes.Address s = Session() def go(): - u1 = User(id=1, + u1 = User(id=1, addresses =[Address(id=1), Address(id=2)] ) u2 = s.merge(u1) @@ -1210,8 +1210,8 @@ class M2ONoUseGetLoadingTest(fixtures.MappedTest): User, Address = self.classes.User, self.classes.Address s = Session() def go(): - u1 = User(id=1, - addresses =[Address(id=1), Address(id=2), + u1 = User(id=1, + addresses =[Address(id=1), Address(id=2), Address(id=3, email='a3')] ) u2 = s.merge(u1) @@ -1223,8 +1223,8 @@ class M2ONoUseGetLoadingTest(fixtures.MappedTest): User, Address = self.classes.User, self.classes.Address s = Session() def go(): - u1 = User(id=1, - addresses =[Address(id=1), Address(id=2), + u1 = User(id=1, + addresses =[Address(id=1), Address(id=2), Address(id=3, email='a3')] ) u2 = s.merge(u1) @@ -1237,8 +1237,8 @@ class M2ONoUseGetLoadingTest(fixtures.MappedTest): class MutableMergeTest(fixtures.MappedTest): @classmethod def define_tables(cls, metadata): - Table("data", metadata, - Column('id', Integer, primary_key=True, + Table("data", metadata, + Column('id', Integer, primary_key=True, test_needs_autoincrement=True), Column('data', PickleType(comparator=operator.eq)) ) @@ -1265,7 +1265,7 @@ class MutableMergeTest(fixtures.MappedTest): class CompositeNullPksTest(fixtures.MappedTest): @classmethod def define_tables(cls, metadata): - Table("data", metadata, + Table("data", metadata, Column('pk1', String(10), primary_key=True), Column('pk2', String(10), primary_key=True), ) @@ -1334,7 +1334,7 @@ class LoadOnPendingTest(fixtures.MappedTest): r = self.classes.Rock(id=0, description='moldy') r.bug = bug m = self.sess.merge(r) - # we've already passed ticket #2374 problem since merge() returned, + # we've already passed ticket #2374 problem since merge() returned, # but for good measure: assert m is not r eq_(m,r) @@ -1354,13 +1354,13 @@ class LoadOnPendingTest(fixtures.MappedTest): self._merge_delete_orphan_o2o_with(self.classes.Bug(id=1)) class PolymorphicOnTest(fixtures.MappedTest): - """Test merge() of polymorphic object when polymorphic_on + """Test merge() of polymorphic object when polymorphic_on isn't a Column""" @classmethod def define_tables(cls, metadata): Table('employees', metadata, - Column('employee_id', Integer, primary_key=True, + Column('employee_id', Integer, primary_key=True, test_needs_autoincrement=True), Column('type', String(1), nullable=False), Column('data', String(50)), @@ -1376,9 +1376,9 @@ class PolymorphicOnTest(fixtures.MappedTest): pass def _setup_polymorphic_on_mappers(self): - employee_mapper = mapper(self.classes.Employee, + employee_mapper = mapper(self.classes.Employee, self.tables.employees, - polymorphic_on=case(value=self.tables.employees.c.type, + polymorphic_on=case(value=self.tables.employees.c.type, whens={ 'E': 'employee', 'M': 'manager', @@ -1398,7 +1398,7 @@ class PolymorphicOnTest(fixtures.MappedTest): """ self._setup_polymorphic_on_mappers() - m = self.classes.Manager(employee_id=55, type='M', + m = self.classes.Manager(employee_id=55, type='M', data='original data') self.sess.add(m) self.sess.commit() @@ -1407,7 +1407,7 @@ class PolymorphicOnTest(fixtures.MappedTest): m = self.classes.Manager(employee_id=55, data='updated data') merged = self.sess.merge(m) - # we've already passed ticket #2449 problem since + # we've already passed ticket #2449 problem since # merge() returned, but for good measure: assert m is not merged eq_(m,merged) diff --git a/test/orm/test_of_type.py b/test/orm/test_of_type.py index 8f4f4e696..f52fe3a8c 100644 --- a/test/orm/test_of_type.py +++ b/test/orm/test_of_type.py @@ -271,7 +271,7 @@ class SubclassRelationshipTest(testing.AssertsCompiledSQL, fixtures.DeclarativeM cls.classes.SubJob return [ ParentThing( - container=DataContainer(name="d1", + container=DataContainer(name="d1", jobs=[ SubJob(attr="s1"), SubJob(attr="s2") @@ -385,7 +385,7 @@ class SubclassRelationshipTest(testing.AssertsCompiledSQL, fixtures.DeclarativeM q = s.query(ParentThing).\ options( subqueryload_all( - ParentThing.container, + ParentThing.container, DataContainer.jobs.of_type(SubJob) )) def go(): @@ -405,7 +405,7 @@ class SubclassRelationshipTest(testing.AssertsCompiledSQL, fixtures.DeclarativeM q = s.query(ParentThing).\ options( joinedload_all( - ParentThing.container, + ParentThing.container, DataContainer.jobs.of_type(SubJob) )) def go(): @@ -430,7 +430,7 @@ class SubclassRelationshipTest(testing.AssertsCompiledSQL, fixtures.DeclarativeM DataContainer.jobs.of_type(Job_P).\ any(Job_P.id < Job.id) ) - self.assert_compile(q, + self.assert_compile(q, "SELECT job.id AS job_id, job.type AS job_type, " "job.container_id " "AS job_container_id " @@ -459,7 +459,7 @@ class SubclassRelationshipTest(testing.AssertsCompiledSQL, fixtures.DeclarativeM DataContainer.jobs.of_type(Job_A).\ any(and_(Job_A.id < Job.id, Job_A.type=='fred')) ) - self.assert_compile(q, + self.assert_compile(q, "SELECT job.id AS job_id, job.type AS job_type, " "job.container_id AS job_container_id " "FROM data_container JOIN job ON data_container.id = job.container_id " @@ -480,7 +480,7 @@ class SubclassRelationshipTest(testing.AssertsCompiledSQL, fixtures.DeclarativeM s = Session() q = s.query(DataContainer).join(DataContainer.jobs.of_type(Job_P)) - self.assert_compile(q, + self.assert_compile(q, "SELECT data_container.id AS data_container_id, " "data_container.name AS data_container_name " "FROM data_container JOIN (SELECT job.id AS job_id, " @@ -498,12 +498,12 @@ class SubclassRelationshipTest(testing.AssertsCompiledSQL, fixtures.DeclarativeM s = Session() q = s.query(DataContainer).join(DataContainer.jobs.of_type(SubJob)) - # note the of_type() here renders JOIN for the Job->SubJob. + # note the of_type() here renders JOIN for the Job->SubJob. # this is because it's using the SubJob mapper directly within # query.join(). When we do joinedload() etc., we're instead # doing a with_polymorphic(), and there we need the join to be # outer by default. - self.assert_compile(q, + self.assert_compile(q, "SELECT data_container.id AS data_container_id, " "data_container.name AS data_container_name " "FROM data_container JOIN (SELECT job.id AS job_id, " @@ -524,7 +524,7 @@ class SubclassRelationshipTest(testing.AssertsCompiledSQL, fixtures.DeclarativeM s = Session() q = s.query(DataContainer).join(DataContainer.jobs.of_type(Job_P)) - self.assert_compile(q, + self.assert_compile(q, "SELECT data_container.id AS data_container_id, " "data_container.name AS data_container_name " "FROM data_container JOIN (SELECT job.id AS job_id, " @@ -544,7 +544,7 @@ class SubclassRelationshipTest(testing.AssertsCompiledSQL, fixtures.DeclarativeM s = Session() q = s.query(DataContainer).join(DataContainer.jobs.of_type(Job_A)) - self.assert_compile(q, + self.assert_compile(q, "SELECT data_container.id AS data_container_id, " "data_container.name AS data_container_name " "FROM data_container JOIN job AS job_1 " @@ -561,7 +561,7 @@ class SubclassRelationshipTest(testing.AssertsCompiledSQL, fixtures.DeclarativeM s = Session() q = s.query(DataContainer).join(Job_P, DataContainer.jobs) - self.assert_compile(q, + self.assert_compile(q, "SELECT data_container.id AS data_container_id, " "data_container.name AS data_container_name " "FROM data_container JOIN (SELECT job.id AS job_id, " diff --git a/test/orm/test_pickled.py b/test/orm/test_pickled.py index bb5bca984..88867edcb 100644 --- a/test/orm/test_pickled.py +++ b/test/orm/test_pickled.py @@ -185,7 +185,7 @@ class PickleTest(fixtures.MappedTest): sess = Session() u1 = User(name='ed', addresses=[ Address( - email_address='ed@bar.com', + email_address='ed@bar.com', ) ]) @@ -219,7 +219,7 @@ class PickleTest(fixtures.MappedTest): sess.expunge_all() u1 = sess.query(User).\ - options(sa.orm.defer('name'), + options(sa.orm.defer('name'), sa.orm.defer('addresses.email_address')).\ get(u1.id) assert 'name' not in u1.__dict__ @@ -305,16 +305,16 @@ class PickleTest(fixtures.MappedTest): u2 = pickle.loads(pickle.dumps(u1)) def test_collection_setstate(self): - """test a particular cycle that requires CollectionAdapter + """test a particular cycle that requires CollectionAdapter to not rely upon InstanceState to deserialize.""" m = MetaData() - c1 = Table('c1', m, - Column('parent_id', String, + c1 = Table('c1', m, + Column('parent_id', String, ForeignKey('p.id'), primary_key=True) ) c2 = Table('c2', m, - Column('parent_id', String, + Column('parent_id', String, ForeignKey('p.id'), primary_key=True) ) p = Table('p', m, @@ -354,7 +354,7 @@ class PickleTest(fixtures.MappedTest): mapper(User, users, properties={ 'addresses':relationship( - Address, + Address, collection_class= attribute_mapped_collection('email_address') ) @@ -365,7 +365,7 @@ class PickleTest(fixtures.MappedTest): for loads, dumps in picklers(): repickled = loads(dumps(u1)) eq_(u1.addresses, repickled.addresses) - eq_(repickled.addresses['email1'], + eq_(repickled.addresses['email1'], Address(email_address="email1")) def test_column_mapped_collection(self): @@ -373,7 +373,7 @@ class PickleTest(fixtures.MappedTest): mapper(User, users, properties={ 'addresses':relationship( - Address, + Address, collection_class= column_mapped_collection( addresses.c.email_address) @@ -388,7 +388,7 @@ class PickleTest(fixtures.MappedTest): for loads, dumps in picklers(): repickled = loads(dumps(u1)) eq_(u1.addresses, repickled.addresses) - eq_(repickled.addresses['email1'], + eq_(repickled.addresses['email1'], Address(email_address="email1")) def test_composite_column_mapped_collection(self): @@ -396,7 +396,7 @@ class PickleTest(fixtures.MappedTest): mapper(User, users, properties={ 'addresses':relationship( - Address, + Address, collection_class= column_mapped_collection([ addresses.c.id, @@ -412,7 +412,7 @@ class PickleTest(fixtures.MappedTest): for loads, dumps in picklers(): repickled = loads(dumps(u1)) eq_(u1.addresses, repickled.addresses) - eq_(repickled.addresses[(1, 'email1')], + eq_(repickled.addresses[(1, 'email1')], Address(id=1, email_address="email1")) class PolymorphicDeferredTest(fixtures.MappedTest): @@ -536,7 +536,7 @@ class CustomSetupTeardownTest(fixtures.MappedTest): test_needs_fk=True ) def test_rebuild_state(self): - """not much of a 'test', but illustrate how to + """not much of a 'test', but illustrate how to remove instance-level state before pickling. """ diff --git a/test/orm/test_rel_fn.py b/test/orm/test_rel_fn.py index 3f43762be..f5fa1d4c9 100644 --- a/test/orm/test_rel_fn.py +++ b/test/orm/test_rel_fn.py @@ -66,23 +66,23 @@ class _JoinFixtures(object): Column('sub_id', Integer, ForeignKey('rel_sub.id')) ) cls.rel_sub = Table('rel_sub', m, - Column('id', Integer, ForeignKey('base_w_sub_rel.id'), + Column('id', Integer, ForeignKey('base_w_sub_rel.id'), primary_key=True) ) cls.base = Table('base', m, Column('id', Integer, primary_key=True), ) cls.sub = Table('sub', m, - Column('id', Integer, ForeignKey('base.id'), + Column('id', Integer, ForeignKey('base.id'), primary_key=True), ) cls.sub_w_base_rel = Table('sub_w_base_rel', m, - Column('id', Integer, ForeignKey('base.id'), + Column('id', Integer, ForeignKey('base.id'), primary_key=True), Column('base_id', Integer, ForeignKey('base.id')) ) - cls.sub_w_sub_rel = Table('sub_w_sub_rel', m, - Column('id', Integer, ForeignKey('base.id'), + cls.sub_w_sub_rel = Table('sub_w_sub_rel', m, + Column('id', Integer, ForeignKey('base.id'), primary_key=True), Column('sub_id', Integer, ForeignKey('sub.id')) ) @@ -91,14 +91,14 @@ class _JoinFixtures(object): Column('base_id', Integer, ForeignKey('base.id')) ) - cls.three_tab_a = Table('three_tab_a', m, + cls.three_tab_a = Table('three_tab_a', m, Column('id', Integer, primary_key=True), ) - cls.three_tab_b = Table('three_tab_b', m, + cls.three_tab_b = Table('three_tab_b', m, Column('id', Integer, primary_key=True), Column('aid', Integer, ForeignKey('three_tab_a.id')) ) - cls.three_tab_c = Table('three_tab_c', m, + cls.three_tab_c = Table('three_tab_c', m, Column('id', Integer, primary_key=True), Column('aid', Integer, ForeignKey('three_tab_a.id')), Column('bid', Integer, ForeignKey('three_tab_b.id')) @@ -112,9 +112,9 @@ class _JoinFixtures(object): else: return True return relationships.JoinCondition( - self.three_tab_a, + self.three_tab_a, self.three_tab_b, - self.three_tab_a, + self.three_tab_a, self.three_tab_b, support_sync=False, can_be_synced_fn=_can_sync, @@ -127,9 +127,9 @@ class _JoinFixtures(object): def _join_fixture_m2m(self, **kw): return relationships.JoinCondition( - self.m2mleft, - self.m2mright, - self.m2mleft, + self.m2mleft, + self.m2mright, + self.m2mleft, self.m2mright, secondary=self.m2msecondary, **kw @@ -137,17 +137,17 @@ class _JoinFixtures(object): def _join_fixture_o2m(self, **kw): return relationships.JoinCondition( - self.left, - self.right, - self.left, + self.left, + self.right, + self.left, self.right, **kw ) def _join_fixture_m2o(self, **kw): return relationships.JoinCondition( - self.right, - self.left, + self.right, + self.left, self.right, self.left, **kw @@ -187,7 +187,7 @@ class _JoinFixtures(object): self.composite_selfref, self.composite_selfref, self.composite_selfref, - remote_side=set([self.composite_selfref.c.id, + remote_side=set([self.composite_selfref.c.id, self.composite_selfref.c.group_id]), **kw ) @@ -278,7 +278,7 @@ class _JoinFixtures(object): ) def _join_fixture_o2m_joined_sub_to_base(self, **kw): - left = self.base.join(self.sub_w_base_rel, + left = self.base.join(self.sub_w_base_rel, self.base.c.id==self.sub_w_base_rel.c.id) return relationships.JoinCondition( left, @@ -290,12 +290,12 @@ class _JoinFixtures(object): def _join_fixture_m2o_joined_sub_to_sub_on_base(self, **kw): # this is a late add - a variant of the test case - # in #2491 where we join on the base cols instead. only + # in #2491 where we join on the base cols instead. only # m2o has a problem at the time of this test. left = self.base.join(self.sub, self.base.c.id==self.sub.c.id) right = self.base.join(self.sub_w_base_rel, self.base.c.id==self.sub_w_base_rel.c.id) return relationships.JoinCondition( - left, + left, right, self.sub, self.sub_w_base_rel, @@ -315,7 +315,7 @@ class _JoinFixtures(object): def _join_fixture_m2o_sub_to_joined_sub(self, **kw): # see test.orm.test_mapper:MapperTest.test_add_column_prop_deannotate, - right = self.base.join(self.right_w_base_rel, + right = self.base.join(self.right_w_base_rel, self.base.c.id==self.right_w_base_rel.c.id) return relationships.JoinCondition( self.right_w_base_rel, @@ -326,7 +326,7 @@ class _JoinFixtures(object): def _join_fixture_m2o_sub_to_joined_sub_func(self, **kw): # see test.orm.test_mapper:MapperTest.test_add_column_prop_deannotate, - right = self.base.join(self.right_w_base_rel, + right = self.base.join(self.right_w_base_rel, self.base.c.id==self.right_w_base_rel.c.id) return relationships.JoinCondition( self.right_w_base_rel, @@ -338,22 +338,22 @@ class _JoinFixtures(object): ) def _join_fixture_o2o_joined_sub_to_base(self, **kw): - left = self.base.join(self.sub, + left = self.base.join(self.sub, self.base.c.id==self.sub.c.id) # see test_relationships->AmbiguousJoinInterpretedAsSelfRef return relationships.JoinCondition( left, self.sub, - left, + left, self.sub, ) def _join_fixture_o2m_to_annotated_func(self, **kw): return relationships.JoinCondition( - self.left, - self.right, - self.left, + self.left, + self.right, + self.left, self.right, primaryjoin=self.left.c.id== foreign(func.foo(self.right.c.lid)), @@ -362,9 +362,9 @@ class _JoinFixtures(object): def _join_fixture_o2m_to_oldstyle_func(self, **kw): return relationships.JoinCondition( - self.left, - self.right, - self.left, + self.left, + self.right, + self.left, self.right, primaryjoin=self.left.c.id== func.foo(self.right.c.lid), @@ -382,10 +382,10 @@ class _JoinFixtures(object): fn ) - def _assert_raises_no_relevant_fks(self, fn, expr, relname, + def _assert_raises_no_relevant_fks(self, fn, expr, relname, primary, *arg, **kw): assert_raises_message( - exc.ArgumentError, + exc.ArgumentError, r"Could not locate any relevant foreign key columns " r"for %s join condition '%s' on relationship %s. " r"Ensure that referencing columns are associated with " @@ -397,10 +397,10 @@ class _JoinFixtures(object): fn, *arg, **kw ) - def _assert_raises_no_equality(self, fn, expr, relname, + def _assert_raises_no_equality(self, fn, expr, relname, primary, *arg, **kw): assert_raises_message( - sa.exc.ArgumentError, + sa.exc.ArgumentError, "Could not locate any simple equality expressions " "involving locally mapped foreign key columns for %s join " "condition '%s' on relationship %s. " @@ -434,7 +434,7 @@ class _JoinFixtures(object): exc.AmbiguousForeignKeysError, "Could not determine join condition between " "parent/child tables on relationship %s - " - "there are no foreign keys linking these tables. " + "there are no foreign keys linking these tables. " % (relname,), fn, *arg, **kw) @@ -544,8 +544,8 @@ class ColumnCollectionsTest(_JoinFixtures, fixtures.TestBase, AssertsCompiledSQL eq_( joincond.local_remote_pairs, [ - (self.left.c.x, self.right.c.x), - (self.left.c.x, self.right.c.y), + (self.left.c.x, self.right.c.x), + (self.left.c.x, self.right.c.y), (self.left.c.y, self.right.c.x), (self.left.c.y, self.right.c.y) ] @@ -557,8 +557,8 @@ class ColumnCollectionsTest(_JoinFixtures, fixtures.TestBase, AssertsCompiledSQL eq_( joincond.local_remote_pairs, [ - (self.left.c.x, self.right.c.x), - (self.left.c.x, self.right.c.y), + (self.left.c.x, self.right.c.x), + (self.left.c.x, self.right.c.y), (self.left.c.y, self.right.c.x), (self.left.c.y, self.right.c.y) ] @@ -640,7 +640,7 @@ class ColumnCollectionsTest(_JoinFixtures, fixtures.TestBase, AssertsCompiledSQL joincond = self._join_fixture_m2o_composite_selfref() eq_( joincond.remote_columns, - set([self.composite_selfref.c.id, + set([self.composite_selfref.c.id, self.composite_selfref.c.group_id]) ) @@ -683,7 +683,7 @@ class ColumnCollectionsTest(_JoinFixtures, fixtures.TestBase, AssertsCompiledSQL joincond = self._join_fixture_m2m() eq_( joincond.local_remote_pairs, - [(self.m2mleft.c.id, self.m2msecondary.c.lid), + [(self.m2mleft.c.id, self.m2msecondary.c.lid), (self.m2mright.c.id, self.m2msecondary.c.rid)] ) @@ -695,7 +695,7 @@ class ColumnCollectionsTest(_JoinFixtures, fixtures.TestBase, AssertsCompiledSQL ) eq_( joincond.local_remote_pairs, - [(self.m2mleft.c.id, self.m2msecondary.c.lid), + [(self.m2mleft.c.id, self.m2msecondary.c.lid), (self.m2mright.c.id, self.m2msecondary.c.rid)] ) @@ -809,20 +809,20 @@ class DetermineJoinTest(_JoinFixtures, fixtures.TestBase, AssertsCompiledSQL): "should be counted as containing a foreign " "key reference to the parent table.", relationships.JoinCondition, - self.left, - self.right_multi_fk, - self.left, - self.right_multi_fk, + self.left, + self.right_multi_fk, + self.left, + self.right_multi_fk, ) def test_determine_join_no_fks_o2m(self): self._assert_raises_no_join( relationships.JoinCondition, "None", None, - self.left, - self.selfref, - self.left, - self.selfref, + self.left, + self.selfref, + self.left, + self.selfref, ) @@ -831,10 +831,10 @@ class DetermineJoinTest(_JoinFixtures, fixtures.TestBase, AssertsCompiledSQL): self._assert_raises_ambig_join( relationships.JoinCondition, "None", self.m2msecondary_ambig_fks, - self.m2mleft, - self.m2mright, - self.m2mleft, - self.m2mright, + self.m2mleft, + self.m2mright, + self.m2mleft, + self.m2mright, secondary=self.m2msecondary_ambig_fks ) @@ -842,22 +842,22 @@ class DetermineJoinTest(_JoinFixtures, fixtures.TestBase, AssertsCompiledSQL): self._assert_raises_no_join( relationships.JoinCondition, "None", self.m2msecondary_no_fks, - self.m2mleft, - self.m2mright, - self.m2mleft, - self.m2mright, + self.m2mleft, + self.m2mright, + self.m2mleft, + self.m2mright, secondary=self.m2msecondary_no_fks ) def _join_fixture_fks_ambig_m2m(self): return relationships.JoinCondition( - self.m2mleft, - self.m2mright, - self.m2mleft, - self.m2mright, + self.m2mleft, + self.m2mright, + self.m2mleft, + self.m2mright, secondary=self.m2msecondary_ambig_fks, consider_as_foreign_keys=[ - self.m2msecondary_ambig_fks.c.lid1, + self.m2msecondary_ambig_fks.c.lid1, self.m2msecondary_ambig_fks.c.rid1] ) @@ -879,8 +879,8 @@ class AdaptedJoinTest(_JoinFixtures, fixtures.TestBase, AssertsCompiledSQL): joincond = self._join_fixture_o2m_selfref() left = select([joincond.parent_selectable]).alias('pj') pj, sj, sec, adapter, ds = joincond.join_targets( - left, - joincond.child_selectable, + left, + joincond.child_selectable, True) self.assert_compile( pj, "pj.id = selfref.sid" @@ -888,8 +888,8 @@ class AdaptedJoinTest(_JoinFixtures, fixtures.TestBase, AssertsCompiledSQL): right = select([joincond.child_selectable]).alias('pj') pj, sj, sec, adapter, ds = joincond.join_targets( - joincond.parent_selectable, - right, + joincond.parent_selectable, + right, True) self.assert_compile( pj, "selfref.id = pj.sid" @@ -899,8 +899,8 @@ class AdaptedJoinTest(_JoinFixtures, fixtures.TestBase, AssertsCompiledSQL): def test_join_targets_o2m_plain(self): joincond = self._join_fixture_o2m() pj, sj, sec, adapter, ds = joincond.join_targets( - joincond.parent_selectable, - joincond.child_selectable, + joincond.parent_selectable, + joincond.child_selectable, False) self.assert_compile( pj, "lft.id = rgt.lid" @@ -910,8 +910,8 @@ class AdaptedJoinTest(_JoinFixtures, fixtures.TestBase, AssertsCompiledSQL): joincond = self._join_fixture_o2m() left = select([joincond.parent_selectable]).alias('pj') pj, sj, sec, adapter, ds = joincond.join_targets( - left, - joincond.child_selectable, + left, + joincond.child_selectable, True) self.assert_compile( pj, "pj.id = rgt.lid" @@ -921,8 +921,8 @@ class AdaptedJoinTest(_JoinFixtures, fixtures.TestBase, AssertsCompiledSQL): joincond = self._join_fixture_o2m() right = select([joincond.child_selectable]).alias('pj') pj, sj, sec, adapter, ds = joincond.join_targets( - joincond.parent_selectable, - right, + joincond.parent_selectable, + right, True) self.assert_compile( pj, "lft.id = pj.lid" @@ -932,11 +932,11 @@ class AdaptedJoinTest(_JoinFixtures, fixtures.TestBase, AssertsCompiledSQL): joincond = self._join_fixture_o2m_composite_selfref() right = select([joincond.child_selectable]).alias('pj') pj, sj, sec, adapter, ds = joincond.join_targets( - joincond.parent_selectable, - right, + joincond.parent_selectable, + right, True) self.assert_compile( - pj, + pj, "pj.group_id = composite_selfref.group_id " "AND composite_selfref.id = pj.parent_id" ) @@ -945,11 +945,11 @@ class AdaptedJoinTest(_JoinFixtures, fixtures.TestBase, AssertsCompiledSQL): joincond = self._join_fixture_m2o_composite_selfref() right = select([joincond.child_selectable]).alias('pj') pj, sj, sec, adapter, ds = joincond.join_targets( - joincond.parent_selectable, - right, + joincond.parent_selectable, + right, True) self.assert_compile( - pj, + pj, "pj.group_id = composite_selfref.group_id " "AND pj.id = composite_selfref.parent_id" ) @@ -966,7 +966,7 @@ class LazyClauseTest(_JoinFixtures, fixtures.TestBase, AssertsCompiledSQL): def _test_lazy_clause_o2m_reverse(self): joincond = self._join_fixture_o2m() self.assert_compile( - relationships.create_lazy_clause(joincond, + relationships.create_lazy_clause(joincond, reverse_direction=True), "" ) diff --git a/test/orm/test_relationships.py b/test/orm/test_relationships.py index 6e610b0cf..394a1fe7a 100644 --- a/test/orm/test_relationships.py +++ b/test/orm/test_relationships.py @@ -16,10 +16,10 @@ from test.orm import _fixtures from sqlalchemy import exc class _RelationshipErrors(object): - def _assert_raises_no_relevant_fks(self, fn, expr, relname, + def _assert_raises_no_relevant_fks(self, fn, expr, relname, primary, *arg, **kw): assert_raises_message( - sa.exc.ArgumentError, + sa.exc.ArgumentError, "Could not locate any relevant foreign key columns " "for %s join condition '%s' on relationship %s. " "Ensure that referencing columns are associated with " @@ -31,10 +31,10 @@ class _RelationshipErrors(object): fn, *arg, **kw ) - def _assert_raises_no_equality(self, fn, expr, relname, + def _assert_raises_no_equality(self, fn, expr, relname, primary, *arg, **kw): assert_raises_message( - sa.exc.ArgumentError, + sa.exc.ArgumentError, "Could not locate any simple equality expressions " "involving locally mapped foreign key columns for %s join " "condition '%s' on relationship %s. " @@ -139,23 +139,23 @@ class DependencyTwoParentTest(fixtures.MappedTest): @classmethod def define_tables(cls, metadata): Table("tbl_a", metadata, - Column("id", Integer, primary_key=True, + Column("id", Integer, primary_key=True, test_needs_autoincrement=True), Column("name", String(128))) Table("tbl_b", metadata, - Column("id", Integer, primary_key=True, + Column("id", Integer, primary_key=True, test_needs_autoincrement=True), Column("name", String(128))) Table("tbl_c", metadata, - Column("id", Integer, primary_key=True, + Column("id", Integer, primary_key=True, test_needs_autoincrement=True), - Column("tbl_a_id", Integer, ForeignKey("tbl_a.id"), + Column("tbl_a_id", Integer, ForeignKey("tbl_a.id"), nullable=False), Column("name", String(128))) Table("tbl_d", metadata, - Column("id", Integer, primary_key=True, + Column("id", Integer, primary_key=True, test_needs_autoincrement=True), - Column("tbl_c_id", Integer, ForeignKey("tbl_c.id"), + Column("tbl_c_id", Integer, ForeignKey("tbl_c.id"), nullable=False), Column("tbl_b_id", Integer, ForeignKey("tbl_b.id")), Column("name", String(128))) @@ -183,11 +183,11 @@ class DependencyTwoParentTest(fixtures.MappedTest): cls.tables.tbl_d) mapper(A, tbl_a, properties=dict( - c_rows=relationship(C, cascade="all, delete-orphan", + c_rows=relationship(C, cascade="all, delete-orphan", backref="a_row"))) mapper(B, tbl_b) mapper(C, tbl_c, properties=dict( - d_rows=relationship(D, cascade="all, delete-orphan", + d_rows=relationship(D, cascade="all, delete-orphan", backref="c_row"))) mapper(D, tbl_d, properties=dict( b_row=relationship(B))) @@ -232,7 +232,7 @@ class DependencyTwoParentTest(fixtures.MappedTest): class CompositeSelfRefFKTest(fixtures.MappedTest): """Tests a composite FK where, in - the relationship(), one col points + the relationship(), one col points to itself in the same table. this is a very unusual case:: @@ -255,7 +255,7 @@ class CompositeSelfRefFKTest(fixtures.MappedTest): @classmethod def define_tables(cls, metadata): Table('company_t', metadata, - Column('company_id', Integer, primary_key=True, + Column('company_id', Integer, primary_key=True, test_needs_autoincrement=True), Column('name', String(30))) @@ -292,9 +292,9 @@ class CompositeSelfRefFKTest(fixtures.MappedTest): mapper(Company, company_t) mapper(Employee, employee_t, properties= { - 'company':relationship(Company, + 'company':relationship(Company, primaryjoin=employee_t.c.company_id== - company_t.c.company_id, + company_t.c.company_id, backref='employees'), 'reports_to':relationship(Employee, primaryjoin= sa.and_( @@ -303,8 +303,8 @@ class CompositeSelfRefFKTest(fixtures.MappedTest): ), remote_side=[employee_t.c.emp_id, employee_t.c.company_id], foreign_keys=[employee_t.c.reports_to_id, employee_t.c.company_id], - backref=backref('employees', - foreign_keys=[employee_t.c.reports_to_id, + backref=backref('employees', + foreign_keys=[employee_t.c.reports_to_id, employee_t.c.company_id])) }) @@ -321,7 +321,7 @@ class CompositeSelfRefFKTest(fixtures.MappedTest): 'company':relationship(Company, backref='employees'), 'reports_to':relationship(Employee, remote_side=[employee_t.c.emp_id, employee_t.c.company_id], - foreign_keys=[employee_t.c.reports_to_id, + foreign_keys=[employee_t.c.reports_to_id, employee_t.c.company_id], backref=backref('employees', foreign_keys= [employee_t.c.reports_to_id, employee_t.c.company_id]) @@ -361,7 +361,7 @@ class CompositeSelfRefFKTest(fixtures.MappedTest): (employee_t.c.reports_to_id, employee_t.c.emp_id), (employee_t.c.company_id, employee_t.c.company_id) ], - foreign_keys=[employee_t.c.reports_to_id, + foreign_keys=[employee_t.c.reports_to_id, employee_t.c.company_id], backref=backref('employees', foreign_keys= [employee_t.c.reports_to_id, employee_t.c.company_id]) @@ -477,7 +477,7 @@ class CompositeJoinPartialFK(fixtures.MappedTest, AssertsCompiledSQL): Column('z', Integer), ) Table("child", metadata, - Column('id', Integer, primary_key=True, + Column('id', Integer, primary_key=True, test_needs_autoincrement=True), Column('x', Integer), Column('y', Integer), @@ -520,7 +520,7 @@ class FKsAsPksTest(fixtures.MappedTest): @classmethod def define_tables(cls, metadata): Table("tableA", metadata, - Column("id",Integer,primary_key=True, + Column("id",Integer,primary_key=True, test_needs_autoincrement=True), Column("foo",Integer,), test_needs_fk=True) @@ -538,7 +538,7 @@ class FKsAsPksTest(fixtures.MappedTest): pass def test_onetoone_switch(self): - """test that active history is enabled on a + """test that active history is enabled on a one-to-many/one that has use_get==True""" tableB, A, B, tableA = (self.tables.tableB, @@ -643,7 +643,7 @@ class FKsAsPksTest(fixtures.MappedTest): sess.flush() def test_delete_cascade_BtoA(self): - """No 'blank the PK' error when the child is to + """No 'blank the PK' error when the child is to be deleted as part of a cascade""" tableB, A, B, tableA = (self.tables.tableB, @@ -674,7 +674,7 @@ class FKsAsPksTest(fixtures.MappedTest): sa.orm.clear_mappers() def test_delete_cascade_AtoB(self): - """No 'blank the PK' error when the child is to + """No 'blank the PK' error when the child is to be deleted as part of a cascade""" tableB, A, B, tableA = (self.tables.tableB, @@ -754,23 +754,23 @@ class FKsAsPksTest(fixtures.MappedTest): assert b1 not in sess class UniqueColReferenceSwitchTest(fixtures.MappedTest): - """test a relationship based on a primary + """test a relationship based on a primary join against a unique non-pk column""" @classmethod def define_tables(cls, metadata): Table("table_a", metadata, - Column("id", Integer, primary_key=True, + Column("id", Integer, primary_key=True, test_needs_autoincrement=True), - Column("ident", String(10), nullable=False, + Column("ident", String(10), nullable=False, unique=True), ) Table("table_b", metadata, - Column("id", Integer, primary_key=True, + Column("id", Integer, primary_key=True, test_needs_autoincrement=True), - Column("a_ident", String(10), - ForeignKey('table_a.ident'), + Column("a_ident", String(10), + ForeignKey('table_a.ident'), nullable=False), ) @@ -873,21 +873,21 @@ class RelationshipToSelectableTest(fixtures.MappedTest): eq_(old.id, new.id) class FKEquatedToConstantTest(fixtures.MappedTest): - """test a relationship with a non-column entity in the primary join, - is not viewonly, and also has the non-column's clause mentioned in the + """test a relationship with a non-column entity in the primary join, + is not viewonly, and also has the non-column's clause mentioned in the foreign keys list. """ @classmethod def define_tables(cls, metadata): - Table('tags', metadata, Column("id", Integer, primary_key=True, + Table('tags', metadata, Column("id", Integer, primary_key=True, test_needs_autoincrement=True), Column("data", String(50)), ) - Table('tag_foo', metadata, - Column("id", Integer, primary_key=True, + Table('tag_foo', metadata, + Column("id", Integer, primary_key=True, test_needs_autoincrement=True), Column('tagid', Integer), Column("data", String(50)), @@ -902,7 +902,7 @@ class FKEquatedToConstantTest(fixtures.MappedTest): pass mapper(Tag, tags, properties={ - 'foo':relationship(TagInstance, + 'foo':relationship(TagInstance, primaryjoin=sa.and_(tag_foo.c.data=='iplc_case', tag_foo.c.tagid==tags.c.id), foreign_keys=[tag_foo.c.tagid, tag_foo.c.data], @@ -921,13 +921,13 @@ class FKEquatedToConstantTest(fixtures.MappedTest): # relationship works eq_( - sess.query(Tag).all(), + sess.query(Tag).all(), [Tag(data='some tag', foo=[TagInstance(data='iplc_case')])] ) # both TagInstances were persisted eq_( - sess.query(TagInstance).order_by(TagInstance.data).all(), + sess.query(TagInstance).order_by(TagInstance.data).all(), [TagInstance(data='iplc_case'), TagInstance(data='not_iplc_case')] ) @@ -935,13 +935,13 @@ class BackrefPropagatesForwardsArgs(fixtures.MappedTest): @classmethod def define_tables(cls, metadata): - Table('users', metadata, - Column('id', Integer, primary_key=True, + Table('users', metadata, + Column('id', Integer, primary_key=True, test_needs_autoincrement=True), Column('name', String(50)) ) - Table('addresses', metadata, - Column('id', Integer, primary_key=True, + Table('addresses', metadata, + Column('id', Integer, primary_key=True, test_needs_autoincrement=True), Column('user_id', Integer), Column('email', String(50)) @@ -962,8 +962,8 @@ class BackrefPropagatesForwardsArgs(fixtures.MappedTest): mapper(User, users, properties={ - 'addresses':relationship(Address, - primaryjoin=addresses.c.user_id==users.c.id, + 'addresses':relationship(Address, + primaryjoin=addresses.c.user_id==users.c.id, foreign_keys=addresses.c.user_id, backref='user') }) @@ -991,13 +991,13 @@ class AmbiguousJoinInterpretedAsSelfRef(fixtures.MappedTest): @classmethod def define_tables(cls, metadata): subscriber_table = Table('subscriber', metadata, - Column('id', Integer, primary_key=True, + Column('id', Integer, primary_key=True, test_needs_autoincrement=True), ) address_table = Table('address', metadata, - Column('subscriber_id', Integer, + Column('subscriber_id', Integer, ForeignKey('subscriber.id'), primary_key=True), Column('type', String(1), primary_key=True), ) @@ -1006,8 +1006,8 @@ class AmbiguousJoinInterpretedAsSelfRef(fixtures.MappedTest): def setup_mappers(cls): subscriber, address = cls.tables.subscriber, cls.tables.address - subscriber_and_address = subscriber.join(address, - and_(address.c.subscriber_id==subscriber.c.id, + subscriber_and_address = subscriber.join(address, + and_(address.c.subscriber_id==subscriber.c.id, address.c.type.in_(['A', 'B', 'C']))) class Address(cls.Comparable): @@ -1020,7 +1020,7 @@ class AmbiguousJoinInterpretedAsSelfRef(fixtures.MappedTest): mapper(Subscriber, subscriber_and_address, properties={ 'id':[subscriber.c.id, address.c.subscriber_id], - 'addresses' : relationship(Address, + 'addresses' : relationship(Address, backref=backref("customer")) }) @@ -1050,8 +1050,8 @@ class AmbiguousJoinInterpretedAsSelfRef(fixtures.MappedTest): eq_( sess.query(Subscriber).order_by(Subscriber.type).all(), [ - Subscriber(id=1, type=u'A'), - Subscriber(id=2, type=u'B'), + Subscriber(id=1, type=u'A'), + Subscriber(id=2, type=u'B'), Subscriber(id=2, type=u'C') ] ) @@ -1123,11 +1123,11 @@ class ManualBackrefTest(_fixtures.FixtureTest): 'dingaling':relationship(Dingaling) }) - assert_raises_message(sa.exc.ArgumentError, + assert_raises_message(sa.exc.ArgumentError, r"reverse_property 'dingaling' on relationship " "User.addresses references " "relationship Address.dingaling, which does not " - "reference mapper Mapper\|User\|users", + "reference mapper Mapper\|User\|users", configure_mappers) class JoinConditionErrorTest(fixtures.TestBase): @@ -1162,7 +1162,7 @@ class JoinConditionErrorTest(fixtures.TestBase): def test_only_column_elements(self): m = MetaData() - t1 = Table('t1', m, + t1 = Table('t1', m, Column('id', Integer, primary_key=True), Column('foo_id', Integer, ForeignKey('t2.id')), ) @@ -1204,16 +1204,16 @@ class JoinConditionErrorTest(fixtures.TestBase): c2 = relationship(C1, **kw) assert_raises_message( - sa.exc.ArgumentError, + sa.exc.ArgumentError, "Column-based expression object expected " - "for argument '%s'; got: '%s', type %r" % + "for argument '%s'; got: '%s', type %r" % (argname, arg[0], type(arg[0])), configure_mappers) def test_fk_error_not_raised_unrelated(self): m = MetaData() - t1 = Table('t1', m, + t1 = Table('t1', m, Column('id', Integer, primary_key=True), Column('foo_id', Integer, ForeignKey('t2.nonexistent_id')), ) @@ -1237,7 +1237,7 @@ class JoinConditionErrorTest(fixtures.TestBase): def test_join_error_raised(self): m = MetaData() - t1 = Table('t1', m, + t1 = Table('t1', m, Column('id', Integer, primary_key=True), ) t2 = Table('t2', m, @@ -1263,27 +1263,27 @@ class JoinConditionErrorTest(fixtures.TestBase): clear_mappers() class TypeMatchTest(fixtures.MappedTest): - """test errors raised when trying to add items + """test errors raised when trying to add items whose type is not handled by a relationship""" @classmethod def define_tables(cls, metadata): Table("a", metadata, - Column('aid', Integer, primary_key=True, + Column('aid', Integer, primary_key=True, test_needs_autoincrement=True), Column('data', String(30))) Table("b", metadata, - Column('bid', Integer, primary_key=True, + Column('bid', Integer, primary_key=True, test_needs_autoincrement=True), Column("a_id", Integer, ForeignKey("a.aid")), Column('data', String(30))) Table("c", metadata, - Column('cid', Integer, primary_key=True, + Column('cid', Integer, primary_key=True, test_needs_autoincrement=True), Column("b_id", Integer, ForeignKey("b.bid")), Column('data', String(30))) Table("d", metadata, - Column('did', Integer, primary_key=True, + Column('did', Integer, primary_key=True, test_needs_autoincrement=True), Column("a_id", Integer, ForeignKey("a.aid")), Column('data', String(30))) @@ -1336,7 +1336,7 @@ class TypeMatchTest(fixtures.MappedTest): sess.add(b1) sess.add(c1) assert_raises_message(sa.orm.exc.FlushError, - "Attempting to flush an item", + "Attempting to flush an item", sess.flush) def test_o2m_nopoly_onflush(self): @@ -1361,7 +1361,7 @@ class TypeMatchTest(fixtures.MappedTest): sess.add(b1) sess.add(c1) assert_raises_message(sa.orm.exc.FlushError, - "Attempting to flush an item", + "Attempting to flush an item", sess.flush) def test_m2o_nopoly_onflush(self): @@ -1382,7 +1382,7 @@ class TypeMatchTest(fixtures.MappedTest): sess.add(b1) sess.add(d1) assert_raises_message(sa.orm.exc.FlushError, - "Attempting to flush an item", + "Attempting to flush an item", sess.flush) def test_m2o_oncascade(self): @@ -1401,7 +1401,7 @@ class TypeMatchTest(fixtures.MappedTest): d1.a = b1 sess = create_session() assert_raises_message(AssertionError, - "doesn't handle objects of type", + "doesn't handle objects of type", sess.add, d1) class TypedAssociationTable(fixtures.MappedTest): @@ -1462,11 +1462,11 @@ class ViewOnlyM2MBackrefTest(fixtures.MappedTest): @classmethod def define_tables(cls, metadata): Table("t1", metadata, - Column('id', Integer, primary_key=True, + Column('id', Integer, primary_key=True, test_needs_autoincrement=True), Column('data', String(40))) Table("t2", metadata, - Column('id', Integer, primary_key=True, + Column('id', Integer, primary_key=True, test_needs_autoincrement=True), Column('data', String(40)), ) @@ -1484,7 +1484,7 @@ class ViewOnlyM2MBackrefTest(fixtures.MappedTest): class B(fixtures.ComparableEntity):pass mapper(A, t1, properties={ - 'bs':relationship(B, secondary=t1t2, + 'bs':relationship(B, secondary=t1t2, backref=backref('as_', viewonly=True)) }) mapper(B, t2) @@ -1508,16 +1508,16 @@ class ViewOnlyOverlappingNames(fixtures.MappedTest): @classmethod def define_tables(cls, metadata): Table("t1", metadata, - Column('id', Integer, primary_key=True, + Column('id', Integer, primary_key=True, test_needs_autoincrement=True), Column('data', String(40))) Table("t2", metadata, - Column('id', Integer, primary_key=True, + Column('id', Integer, primary_key=True, test_needs_autoincrement=True), Column('data', String(40)), Column('t1id', Integer, ForeignKey('t1.id'))) Table("t3", metadata, - Column('id', Integer, primary_key=True, + Column('id', Integer, primary_key=True, test_needs_autoincrement=True), Column('data', String(40)), Column('t2id', Integer, ForeignKey('t2.id'))) @@ -1575,16 +1575,16 @@ class ViewOnlyUniqueNames(fixtures.MappedTest): @classmethod def define_tables(cls, metadata): Table("t1", metadata, - Column('t1id', Integer, primary_key=True, + Column('t1id', Integer, primary_key=True, test_needs_autoincrement=True), Column('data', String(40))) Table("t2", metadata, - Column('t2id', Integer, primary_key=True, + Column('t2id', Integer, primary_key=True, test_needs_autoincrement=True), Column('data', String(40)), Column('t1id_ref', Integer, ForeignKey('t1.t1id'))) Table("t3", metadata, - Column('t3id', Integer, primary_key=True, + Column('t3id', Integer, primary_key=True, test_needs_autoincrement=True), Column('data', String(40)), Column('t2id_ref', Integer, ForeignKey('t2.t2id'))) @@ -1765,11 +1765,11 @@ class ViewOnlyRepeatedLocalColumn(fixtures.MappedTest): @classmethod def define_tables(cls, metadata): Table('foos', metadata, - Column('id', Integer, primary_key=True, + Column('id', Integer, primary_key=True, test_needs_autoincrement=True), Column('data', String(50))) - Table('bars', metadata, Column('id', Integer, primary_key=True, + Table('bars', metadata, Column('id', Integer, primary_key=True, test_needs_autoincrement=True), Column('fid1', Integer, ForeignKey('foos.id')), Column('fid2', Integer, ForeignKey('foos.id')), @@ -1816,16 +1816,16 @@ class ViewOnlyComplexJoin(_RelationshipErrors, fixtures.MappedTest): @classmethod def define_tables(cls, metadata): Table('t1', metadata, - Column('id', Integer, primary_key=True, + Column('id', Integer, primary_key=True, test_needs_autoincrement=True), Column('data', String(50))) Table('t2', metadata, - Column('id', Integer, primary_key=True, + Column('id', Integer, primary_key=True, test_needs_autoincrement=True), Column('data', String(50)), Column('t1id', Integer, ForeignKey('t1.id'))) Table('t3', metadata, - Column('id', Integer, primary_key=True, + Column('id', Integer, primary_key=True, test_needs_autoincrement=True), Column('data', String(50))) Table('t2tot3', metadata, @@ -1902,11 +1902,11 @@ class ExplicitLocalRemoteTest(fixtures.MappedTest): @classmethod def define_tables(cls, metadata): Table('t1', metadata, - Column('id', String(50), primary_key=True, + Column('id', String(50), primary_key=True, test_needs_autoincrement=True), Column('data', String(50))) Table('t2', metadata, - Column('id', Integer, primary_key=True, + Column('id', Integer, primary_key=True, test_needs_autoincrement=True), Column('data', String(50)), Column('t1id', String(50))) @@ -2104,25 +2104,25 @@ class InvalidRemoteSideTest(fixtures.MappedTest): 't1s':relationship(T1, backref='parent') }) - assert_raises_message(sa.exc.ArgumentError, + assert_raises_message(sa.exc.ArgumentError, "T1.t1s and back-reference T1.parent are " "both of the same direction <symbol 'ONETOMANY>. Did you " - "mean to set remote_side on the many-to-one side ?", + "mean to set remote_side on the many-to-one side ?", configure_mappers) def test_m2o_backref(self): T1, t1 = self.classes.T1, self.tables.t1 mapper(T1, t1, properties={ - 't1s':relationship(T1, - backref=backref('parent', remote_side=t1.c.id), + 't1s':relationship(T1, + backref=backref('parent', remote_side=t1.c.id), remote_side=t1.c.id) }) - assert_raises_message(sa.exc.ArgumentError, + assert_raises_message(sa.exc.ArgumentError, "T1.t1s and back-reference T1.parent are " "both of the same direction <symbol 'MANYTOONE>. Did you " - "mean to set remote_side on the many-to-one side ?", + "mean to set remote_side on the many-to-one side ?", configure_mappers) def test_o2m_explicit(self): @@ -2134,25 +2134,25 @@ class InvalidRemoteSideTest(fixtures.MappedTest): }) # can't be sure of ordering here - assert_raises_message(sa.exc.ArgumentError, + assert_raises_message(sa.exc.ArgumentError, "both of the same direction <symbol 'ONETOMANY>. Did you " - "mean to set remote_side on the many-to-one side ?", + "mean to set remote_side on the many-to-one side ?", configure_mappers) def test_m2o_explicit(self): T1, t1 = self.classes.T1, self.tables.t1 mapper(T1, t1, properties={ - 't1s':relationship(T1, back_populates='parent', + 't1s':relationship(T1, back_populates='parent', remote_side=t1.c.id), - 'parent':relationship(T1, back_populates='t1s', + 'parent':relationship(T1, back_populates='t1s', remote_side=t1.c.id) }) # can't be sure of ordering here - assert_raises_message(sa.exc.ArgumentError, + assert_raises_message(sa.exc.ArgumentError, "both of the same direction <symbol 'MANYTOONE>. Did you " - "mean to set remote_side on the many-to-one side ?", + "mean to set remote_side on the many-to-one side ?", configure_mappers) class AmbiguousFKResolutionTest(_RelationshipErrors, fixtures.MappedTest): @@ -2166,11 +2166,11 @@ class AmbiguousFKResolutionTest(_RelationshipErrors, fixtures.MappedTest): Column('aid_1', Integer, ForeignKey('a.id')), Column('aid_2', Integer, ForeignKey('a.id')), ) - Table("atob", metadata, + Table("atob", metadata, Column('aid', Integer), Column('bid', Integer), ) - Table("atob_ambiguous", metadata, + Table("atob_ambiguous", metadata, Column('aid1', Integer, ForeignKey('a.id')), Column('bid1', Integer, ForeignKey('b.id')), Column('aid2', Integer, ForeignKey('a.id')), @@ -2276,7 +2276,7 @@ class AmbiguousFKResolutionTest(_RelationshipErrors, fixtures.MappedTest): A, B = self.classes.A, self.classes.B a, b, a_to_b = self.tables.a, self.tables.b, self.tables.atob_ambiguous mapper(A, a, properties={ - 'bs':relationship(B, secondary=a_to_b, + 'bs':relationship(B, secondary=a_to_b, foreign_keys=[a_to_b.c.aid1, a_to_b.c.bid1]) }) mapper(B, b) @@ -2378,7 +2378,7 @@ class InvalidRelationshipEscalationTest(_RelationshipErrors, fixtures.MappedTest self.tables.bars_with_fks, self.tables.foos) - # very unique - the join between parent/child + # very unique - the join between parent/child # has no fks, but there is an fk join between two other # tables in the join condition, for those users that try creating # these big-long-string-of-joining-many-tables primaryjoins. @@ -2396,7 +2396,7 @@ class InvalidRelationshipEscalationTest(_RelationshipErrors, fixtures.MappedTest self._assert_raises_no_equality( sa.orm.configure_mappers, "bars_with_fks.fid = foos_with_fks.id " - "AND foos_with_fks.id = foos.id", + "AND foos_with_fks.id = foos.id", "Foo.bars", "primary" ) @@ -2470,7 +2470,7 @@ class InvalidRelationshipEscalationTest(_RelationshipErrors, fixtures.MappedTest primaryjoin=foos.c.id>foos.c.fid)}) mapper(Bar, bars) - self._assert_raises_no_relevant_fks(configure_mappers, + self._assert_raises_no_relevant_fks(configure_mappers, "foos.id > foos.fid", "Foo.foos", "primary" ) @@ -2487,7 +2487,7 @@ class InvalidRelationshipEscalationTest(_RelationshipErrors, fixtures.MappedTest foreign_keys=[foos.c.fid])}) mapper(Bar, bars) - self._assert_raises_no_equality(configure_mappers, + self._assert_raises_no_equality(configure_mappers, "foos.id > foos.fid", "Foo.foos", "primary" ) @@ -2623,16 +2623,16 @@ class InvalidRelationshipEscalationTestM2M(_RelationshipErrors, fixtures.MappedT Column('id', Integer, primary_key=True)) Table('foobars_with_fks', metadata, - Column('fid', Integer, ForeignKey('foos.id')), + Column('fid', Integer, ForeignKey('foos.id')), Column('bid', Integer, ForeignKey('bars.id')) ) Table('foobars_with_many_columns', metadata, - Column('fid', Integer), + Column('fid', Integer), Column('bid', Integer), - Column('fid1', Integer), + Column('fid1', Integer), Column('bid1', Integer), - Column('fid2', Integer), + Column('fid2', Integer), Column('bid2', Integer), ) @@ -2656,7 +2656,7 @@ class InvalidRelationshipEscalationTestM2M(_RelationshipErrors, fixtures.MappedT self._assert_raises_no_join( configure_mappers, - "Foo.bars", + "Foo.bars", "foobars" ) @@ -2675,7 +2675,7 @@ class InvalidRelationshipEscalationTestM2M(_RelationshipErrors, fixtures.MappedT self._assert_raises_no_join( configure_mappers, - "Foo.bars", + "Foo.bars", "foobars" ) @@ -2688,7 +2688,7 @@ class InvalidRelationshipEscalationTestM2M(_RelationshipErrors, fixtures.MappedT self.tables.foos) mapper(Foo, foos, properties={ - 'bars': relationship(Bar, secondary=foobars, + 'bars': relationship(Bar, secondary=foobars, primaryjoin=foos.c.id==foobars.c.fid, secondaryjoin=foobars.c.bid==bars.c.id)}) mapper(Bar, bars) @@ -2704,8 +2704,8 @@ class InvalidRelationshipEscalationTestM2M(_RelationshipErrors, fixtures.MappedT sa.orm.clear_mappers() mapper(Foo, foos, properties={ - 'bars': relationship(Bar, - secondary=foobars_with_many_columns, + 'bars': relationship(Bar, + secondary=foobars_with_many_columns, primaryjoin=foos.c.id== foobars_with_many_columns.c.fid, secondaryjoin=foobars_with_many_columns.c.bid== @@ -2738,7 +2738,7 @@ class InvalidRelationshipEscalationTestM2M(_RelationshipErrors, fixtures.MappedT mapper(Bar, bars) self._assert_raises_no_equality( - configure_mappers, + configure_mappers, 'foos.id > foobars.fid', "Foo.bars", "primary") @@ -2751,7 +2751,7 @@ class InvalidRelationshipEscalationTestM2M(_RelationshipErrors, fixtures.MappedT secondaryjoin=foobars_with_fks.c.bid<=bars.c.id)}) mapper(Bar, bars) self._assert_raises_no_equality( - configure_mappers, + configure_mappers, 'foos.id > foobars_with_fks.fid', "Foo.bars", "primary") @@ -2832,7 +2832,7 @@ class ActiveHistoryFlagTest(_fixtures.FixtureTest): User, users = self.classes.User, self.tables.users mapper(User, users, properties={ - 'name':column_property(users.c.name, + 'name':column_property(users.c.name, active_history=True) }) u1 = User(name='jack') @@ -2867,8 +2867,8 @@ class ActiveHistoryFlagTest(_fixtures.FixtureTest): other.description == self.description mapper(Order, orders, properties={ 'composite':composite( - MyComposite, - orders.c.description, + MyComposite, + orders.c.description, orders.c.isopen, active_history=True) }) diff --git a/test/orm/test_selectable.py b/test/orm/test_selectable.py index 97849f845..1a46e3b6d 100644 --- a/test/orm/test_selectable.py +++ b/test/orm/test_selectable.py @@ -44,7 +44,7 @@ class SelectableNoFromsTest(fixtures.MappedTest, AssertsCompiledSQL): selectable = select(["x", "y", "z"]).alias() assert_raises_message( - sa.exc.ArgumentError, + sa.exc.ArgumentError, "could not assemble any primary key columns", mapper, Subset, selectable ) diff --git a/test/orm/test_session.py b/test/orm/test_session.py index 828571f9d..81188dec9 100644 --- a/test/orm/test_session.py +++ b/test/orm/test_session.py @@ -1071,7 +1071,7 @@ class IsModifiedTest(_fixtures.FixtureTest): s.expire_all() u.name = 'newname' - # can't predict result here + # can't predict result here # deterministically, depending on if # 'name' or 'addresses' is tested first mod = s.is_modified(u) diff --git a/test/orm/test_subquery_relations.py b/test/orm/test_subquery_relations.py index 53c50634e..37b7edb6b 100644 --- a/test/orm/test_subquery_relations.py +++ b/test/orm/test_subquery_relations.py @@ -809,7 +809,7 @@ class LoadOnExistingTest(_fixtures.FixtureTest): User, Order, Item = self.classes.User, \ self.classes.Order, self.classes.Item mapper(User, self.tables.users, properties={ - 'orders':relationship(Order), + 'orders':relationship(Order), }) mapper(Order, self.tables.orders, properties={ 'items':relationship(Item, secondary=self.tables.order_items), @@ -1197,7 +1197,7 @@ class SelfReferentialTest(fixtures.MappedTest): class InheritanceToRelatedTest(fixtures.MappedTest): @classmethod def define_tables(cls, metadata): - Table('foo', metadata, + Table('foo', metadata, Column("id", Integer, primary_key=True), Column("type", String(50)), Column("related_id", Integer, ForeignKey("related.id")) @@ -1254,9 +1254,9 @@ class InheritanceToRelatedTest(fixtures.MappedTest): mapper(cls.classes.Foo, cls.tables.foo, properties={ 'related':relationship(cls.classes.Related) }, polymorphic_on=cls.tables.foo.c.type) - mapper(cls.classes.Bar, cls.tables.bar, polymorphic_identity='bar', + mapper(cls.classes.Bar, cls.tables.bar, polymorphic_identity='bar', inherits=cls.classes.Foo) - mapper(cls.classes.Baz, cls.tables.baz, polymorphic_identity='baz', + mapper(cls.classes.Baz, cls.tables.baz, polymorphic_identity='baz', inherits=cls.classes.Foo) mapper(cls.classes.Related, cls.tables.related) diff --git a/test/orm/test_transaction.py b/test/orm/test_transaction.py index 9faf54579..b657cd464 100644 --- a/test/orm/test_transaction.py +++ b/test/orm/test_transaction.py @@ -65,7 +65,7 @@ class SessionTransactionTest(FixtureTest): try: conn = testing.db.connect() trans = conn.begin() - sess = create_session(bind=conn, autocommit=False, + sess = create_session(bind=conn, autocommit=False, autoflush=True) u1 = User(name='u1') sess.add(u1) @@ -133,7 +133,7 @@ class SessionTransactionTest(FixtureTest): mapper(Address, addresses) engine2 = engines.testing_engine() - sess = create_session(autocommit=True, autoflush=False, + sess = create_session(autocommit=True, autoflush=False, twophase=True) sess.bind_mapper(User, testing.db) sess.bind_mapper(Address, engine2) @@ -338,7 +338,7 @@ class SessionTransactionTest(FixtureTest): sess.add(u2) def go(): sess.rollback() - assert_warnings(go, + assert_warnings(go, ["Session's state has been changed on a " "non-active transaction - this state " "will be discarded."], @@ -351,7 +351,7 @@ class SessionTransactionTest(FixtureTest): u1.name = 'newname' def go(): sess.rollback() - assert_warnings(go, + assert_warnings(go, ["Session's state has been changed on a " "non-active transaction - this state " "will be discarded."], @@ -364,7 +364,7 @@ class SessionTransactionTest(FixtureTest): sess.delete(u1) def go(): sess.rollback() - assert_warnings(go, + assert_warnings(go, ["Session's state has been changed on a " "non-active transaction - this state " "will be discarded."], @@ -412,7 +412,7 @@ class _LocalFixture(FixtureTest): users, addresses = cls.tables.users, cls.tables.addresses mapper(User, users, properties={ 'addresses':relationship(Address, backref='user', - cascade="all, delete-orphan", + cascade="all, delete-orphan", order_by=addresses.c.id), }) mapper(Address, addresses) @@ -456,7 +456,7 @@ class FixtureDataTest(_LocalFixture): class CleanSavepointTest(FixtureTest): """test the behavior for [ticket:2452] - rollback on begin_nested() only expires objects tracked as being modified in that transaction. - + """ run_inserts = None @@ -491,7 +491,7 @@ class CleanSavepointTest(FixtureTest): def test_rollback_ignores_clean_on_savepoint_agg_upd_eval(self): User, users = self.classes.User, self.tables.users def update_fn(s, u2): - s.query(User).filter_by(name='u2').update(dict(name='u2modified'), + s.query(User).filter_by(name='u2').update(dict(name='u2modified'), synchronize_session='evaluate') self._run_test(update_fn) @@ -499,7 +499,7 @@ class CleanSavepointTest(FixtureTest): def test_rollback_ignores_clean_on_savepoint_agg_upd_fetch(self): User, users = self.classes.User, self.tables.users def update_fn(s, u2): - s.query(User).filter_by(name='u2').update(dict(name='u2modified'), + s.query(User).filter_by(name='u2').update(dict(name='u2modified'), synchronize_session='fetch') self._run_test(update_fn) @@ -614,7 +614,7 @@ class AutoExpireTest(_LocalFixture): u1.addresses.remove(a1) s.flush() - eq_(s.query(Address).filter(Address.email_address=='foo').all(), + eq_(s.query(Address).filter(Address.email_address=='foo').all(), []) s.rollback() assert a1 not in s.deleted @@ -688,7 +688,7 @@ class RollbackRecoverTest(_LocalFixture): s.commit() eq_( s.query(User).all(), - [User(id=1, name='edward', + [User(id=1, name='edward', addresses=[Address(email_address='foober')])] ) @@ -719,7 +719,7 @@ class RollbackRecoverTest(_LocalFixture): s.commit() eq_( s.query(User).all(), - [User(id=1, name='edward', + [User(id=1, name='edward', addresses=[Address(email_address='foober')])] ) @@ -740,17 +740,17 @@ class SavepointTest(_LocalFixture): u1.name = 'edward' u2.name = 'jackward' s.add_all([u3, u4]) - eq_(s.query(User.name).order_by(User.id).all(), + eq_(s.query(User.name).order_by(User.id).all(), [('edward',), ('jackward',), ('wendy',), ('foo',)]) s.rollback() assert u1.name == 'ed' assert u2.name == 'jack' - eq_(s.query(User.name).order_by(User.id).all(), + eq_(s.query(User.name).order_by(User.id).all(), [('ed',), ('jack',)]) s.commit() assert u1.name == 'ed' assert u2.name == 'jack' - eq_(s.query(User.name).order_by(User.id).all(), + eq_(s.query(User.name).order_by(User.id).all(), [('ed',), ('jack',)]) @testing.requires.savepoints @@ -781,18 +781,18 @@ class SavepointTest(_LocalFixture): u1.name = 'edward' u2.name = 'jackward' s.add_all([u3, u4]) - eq_(s.query(User.name).order_by(User.id).all(), + eq_(s.query(User.name).order_by(User.id).all(), [('edward',), ('jackward',), ('wendy',), ('foo',)]) s.commit() def go(): assert u1.name == 'edward' assert u2.name == 'jackward' - eq_(s.query(User.name).order_by(User.id).all(), + eq_(s.query(User.name).order_by(User.id).all(), [('edward',), ('jackward',), ('wendy',), ('foo',)]) self.assert_sql_count(testing.db, go, 1) s.commit() - eq_(s.query(User.name).order_by(User.id).all(), + eq_(s.query(User.name).order_by(User.id).all(), [('edward',), ('jackward',), ('wendy',), ('foo',)]) @testing.requires.savepoints @@ -810,7 +810,7 @@ class SavepointTest(_LocalFixture): s.add(u2) eq_(s.query(User).order_by(User.id).all(), [ - User(name='edward', addresses=[Address(email_address='foo'), + User(name='edward', addresses=[Address(email_address='foo'), Address(email_address='bar')]), User(name='jack', addresses=[Address(email_address='bat')]) ] @@ -818,14 +818,14 @@ class SavepointTest(_LocalFixture): s.rollback() eq_(s.query(User).order_by(User.id).all(), [ - User(name='edward', addresses=[Address(email_address='foo'), + User(name='edward', addresses=[Address(email_address='foo'), Address(email_address='bar')]), ] ) s.commit() eq_(s.query(User).order_by(User.id).all(), [ - User(name='edward', addresses=[Address(email_address='foo'), + User(name='edward', addresses=[Address(email_address='foo'), Address(email_address='bar')]), ] ) @@ -949,7 +949,7 @@ class AccountingFlagsTest(_LocalFixture): def test_preflush_no_accounting(self): User, users = self.classes.User, self.tables.users - sess = Session(_enable_transaction_accounting=False, + sess = Session(_enable_transaction_accounting=False, autocommit=True, autoflush=False) u1 = User(name='ed') sess.add(u1) diff --git a/test/orm/test_unitofworkv2.py b/test/orm/test_unitofworkv2.py index 30557edef..0dbe50910 100644 --- a/test/orm/test_unitofworkv2.py +++ b/test/orm/test_unitofworkv2.py @@ -28,7 +28,7 @@ class AssertsUOW(object): print postsort_actions eq_(len(postsort_actions), expected, postsort_actions) -class UOWTest(_fixtures.FixtureTest, +class UOWTest(_fixtures.FixtureTest, testing.AssertsExecutionResults, AssertsUOW): run_inserts = None @@ -55,17 +55,17 @@ class RudimentaryFlushTest(UOWTest): sess.flush, CompiledSQL( "INSERT INTO users (name) VALUES (:name)", - {'name': 'u1'} + {'name': 'u1'} ), CompiledSQL( "INSERT INTO addresses (user_id, email_address) " "VALUES (:user_id, :email_address)", - lambda ctx: {'email_address': 'a1', 'user_id':u1.id} + lambda ctx: {'email_address': 'a1', 'user_id':u1.id} ), CompiledSQL( "INSERT INTO addresses (user_id, email_address) " "VALUES (:user_id, :email_address)", - lambda ctx: {'email_address': 'a2', 'user_id':u1.id} + lambda ctx: {'email_address': 'a2', 'user_id':u1.id} ), ) @@ -160,17 +160,17 @@ class RudimentaryFlushTest(UOWTest): sess.flush, CompiledSQL( "INSERT INTO users (name) VALUES (:name)", - {'name': 'u1'} + {'name': 'u1'} ), CompiledSQL( "INSERT INTO addresses (user_id, email_address) " "VALUES (:user_id, :email_address)", - lambda ctx: {'email_address': 'a1', 'user_id':u1.id} + lambda ctx: {'email_address': 'a1', 'user_id':u1.id} ), CompiledSQL( "INSERT INTO addresses (user_id, email_address) " "VALUES (:user_id, :email_address)", - lambda ctx: {'email_address': 'a2', 'user_id':u1.id} + lambda ctx: {'email_address': 'a2', 'user_id':u1.id} ), ) @@ -280,8 +280,8 @@ class RudimentaryFlushTest(UOWTest): session.delete(c2) session.delete(parent) - # testing that relationships - # are loaded even if all ids/references are + # testing that relationships + # are loaded even if all ids/references are # expired self.assert_sql_execution( testing.db, @@ -462,7 +462,7 @@ class RudimentaryFlushTest(UOWTest): testing.db, sess.flush, CompiledSQL( - "INSERT INTO users (id, name) VALUES (:id, :name)", + "INSERT INTO users (id, name) VALUES (:id, :name)", {'id':1, 'name':'u1'}), CompiledSQL( "INSERT INTO addresses (id, user_id, email_address) " @@ -511,9 +511,9 @@ class RudimentaryFlushTest(UOWTest): sess.flush, CompiledSQL( "INSERT INTO nodes (id, parent_id, data) VALUES " - "(:id, :parent_id, :data)", - [{'parent_id': None, 'data': None, 'id': 1}, - {'parent_id': 1, 'data': None, 'id': 2}, + "(:id, :parent_id, :data)", + [{'parent_id': None, 'data': None, 'id': 1}, + {'parent_id': 1, 'data': None, 'id': 2}, {'parent_id': 2, 'data': None, 'id': 3}] ), ) @@ -561,7 +561,7 @@ class RudimentaryFlushTest(UOWTest): testing.db, sess.flush, CompiledSQL("UPDATE items SET description=:description " - "WHERE items.id = :items_id", + "WHERE items.id = :items_id", lambda ctx:{'description':'i2', 'items_id':i1.id}) ) @@ -689,9 +689,9 @@ class SingleCycleTest(UOWTest): self.assert_sql_execution( testing.db, sess.flush, - CompiledSQL("DELETE FROM nodes WHERE nodes.id = :id", + CompiledSQL("DELETE FROM nodes WHERE nodes.id = :id", lambda ctx:[{'id':n2.id}, {'id':n3.id}]), - CompiledSQL("DELETE FROM nodes WHERE nodes.id = :id", + CompiledSQL("DELETE FROM nodes WHERE nodes.id = :id", lambda ctx: {'id':n1.id}) ) @@ -715,13 +715,13 @@ class SingleCycleTest(UOWTest): sess.flush, AllOf( CompiledSQL("UPDATE nodes SET parent_id=:parent_id " - "WHERE nodes.id = :nodes_id", + "WHERE nodes.id = :nodes_id", lambda ctx: {'nodes_id':n3.id, 'parent_id':None}), CompiledSQL("UPDATE nodes SET parent_id=:parent_id " - "WHERE nodes.id = :nodes_id", + "WHERE nodes.id = :nodes_id", lambda ctx: {'nodes_id':n2.id, 'parent_id':None}), ), - CompiledSQL("DELETE FROM nodes WHERE nodes.id = :id", + CompiledSQL("DELETE FROM nodes WHERE nodes.id = :id", lambda ctx:{'id':n1.id}) ) @@ -781,9 +781,9 @@ class SingleCycleTest(UOWTest): self.assert_sql_execution( testing.db, sess.flush, - CompiledSQL("DELETE FROM nodes WHERE nodes.id = :id", + CompiledSQL("DELETE FROM nodes WHERE nodes.id = :id", lambda ctx:[{'id':n2.id},{'id':n3.id}]), - CompiledSQL("DELETE FROM nodes WHERE nodes.id = :id", + CompiledSQL("DELETE FROM nodes WHERE nodes.id = :id", lambda ctx: {'id':n1.id}) ) @@ -834,7 +834,7 @@ class SingleCycleTest(UOWTest): Node, nodes = self.classes.Node, self.tables.nodes mapper(Node, nodes, properties={ - 'children':relationship(Node, + 'children':relationship(Node, backref=backref('parent', remote_side=nodes.c.id)) }) @@ -856,7 +856,7 @@ class SingleCycleTest(UOWTest): Node, nodes = self.classes.Node, self.tables.nodes mapper(Node, nodes, properties={ - 'children':relationship(Node, + 'children':relationship(Node, backref=backref('parent', remote_side=nodes.c.id) ) }) @@ -875,37 +875,37 @@ class SingleCycleTest(UOWTest): sess.flush, CompiledSQL( "INSERT INTO nodes (parent_id, data) VALUES " - "(:parent_id, :data)", + "(:parent_id, :data)", lambda ctx:{'parent_id':None, 'data':'n1'} ), CompiledSQL( "INSERT INTO nodes (parent_id, data) VALUES " - "(:parent_id, :data)", + "(:parent_id, :data)", lambda ctx:{'parent_id':n1.id, 'data':'n11'} ), CompiledSQL( "INSERT INTO nodes (parent_id, data) VALUES " - "(:parent_id, :data)", + "(:parent_id, :data)", lambda ctx:{'parent_id':n1.id, 'data':'n12'} ), CompiledSQL( "INSERT INTO nodes (parent_id, data) VALUES " - "(:parent_id, :data)", + "(:parent_id, :data)", lambda ctx:{'parent_id':n1.id, 'data':'n13'} ), CompiledSQL( "INSERT INTO nodes (parent_id, data) VALUES " - "(:parent_id, :data)", + "(:parent_id, :data)", lambda ctx:{'parent_id':n12.id, 'data':'n121'} ), CompiledSQL( "INSERT INTO nodes (parent_id, data) VALUES " - "(:parent_id, :data)", + "(:parent_id, :data)", lambda ctx:{'parent_id':n12.id, 'data':'n122'} ), CompiledSQL( "INSERT INTO nodes (parent_id, data) VALUES " - "(:parent_id, :data)", + "(:parent_id, :data)", lambda ctx:{'parent_id':n12.id, 'data':'n123'} ), ) @@ -975,8 +975,8 @@ class SingleCycleTest(UOWTest): session.delete(c2) session.delete(parent) - # testing that relationships - # are loaded even if all ids/references are + # testing that relationships + # are loaded even if all ids/references are # expired self.assert_sql_execution( testing.db, @@ -1060,29 +1060,29 @@ class SingleCyclePlusAttributeTest(fixtures.MappedTest, n1.foobars.append(FooBar()) # saveupdateall/deleteall for FooBar added here, - # plus processstate node.foobars + # plus processstate node.foobars # currently the "all" procs stay in pairs self._assert_uow_size(sess, 6) sess.flush() -class SingleCycleM2MTest(fixtures.MappedTest, +class SingleCycleM2MTest(fixtures.MappedTest, testing.AssertsExecutionResults, AssertsUOW): @classmethod def define_tables(cls, metadata): nodes = Table('nodes', metadata, - Column('id', Integer, - primary_key=True, + Column('id', Integer, + primary_key=True, test_needs_autoincrement=True), Column('data', String(30)), Column('favorite_node_id', Integer, ForeignKey('nodes.id')) ) node_to_nodes =Table('node_to_nodes', metadata, - Column('left_node_id', Integer, + Column('left_node_id', Integer, ForeignKey('nodes.id'),primary_key=True), - Column('right_node_id', Integer, + Column('right_node_id', Integer, ForeignKey('nodes.id'),primary_key=True), ) @@ -1127,10 +1127,10 @@ class SingleCycleM2MTest(fixtures.MappedTest, node_to_nodes.c.right_node_id).\ order_by(node_to_nodes.c.left_node_id, node_to_nodes.c.right_node_id).\ - all(), + all(), sorted([ - (n1.id, n2.id), (n1.id, n3.id), (n1.id, n4.id), - (n2.id, n3.id), (n2.id, n5.id), + (n1.id, n2.id), (n1.id, n3.id), (n1.id, n4.id), + (n2.id, n3.id), (n2.id, n5.id), (n3.id, n5.id), (n3.id, n4.id) ]) ) @@ -1155,8 +1155,8 @@ class SingleCycleM2MTest(fixtures.MappedTest, "node_to_nodes.left_node_id = :left_node_id AND " "node_to_nodes.right_node_id = :right_node_id", lambda ctx:[ - {'right_node_id': n2.id, 'left_node_id': n1.id}, - {'right_node_id': n3.id, 'left_node_id': n1.id}, + {'right_node_id': n2.id, 'left_node_id': n1.id}, + {'right_node_id': n3.id, 'left_node_id': n1.id}, {'right_node_id': n4.id, 'left_node_id': n1.id} ] ), @@ -1182,9 +1182,9 @@ class SingleCycleM2MTest(fixtures.MappedTest, "= :left_node_id AND node_to_nodes.right_node_id = " ":right_node_id", lambda ctx:[ - {'right_node_id': n5.id, 'left_node_id': n3.id}, - {'right_node_id': n4.id, 'left_node_id': n3.id}, - {'right_node_id': n3.id, 'left_node_id': n2.id}, + {'right_node_id': n5.id, 'left_node_id': n3.id}, + {'right_node_id': n4.id, 'left_node_id': n3.id}, + {'right_node_id': n3.id, 'left_node_id': n2.id}, {'right_node_id': n5.id, 'left_node_id': n2.id} ] ), @@ -1204,7 +1204,7 @@ class RowswitchAccountingTest(fixtures.MappedTest): Table('parent', metadata, Column('id', Integer, primary_key=True) ) - Table('child', metadata, + Table('child', metadata, Column('id', Integer, ForeignKey('parent.id'), primary_key=True) ) @@ -1219,7 +1219,7 @@ class RowswitchAccountingTest(fixtures.MappedTest): pass mapper(Parent, parent, properties={ - 'child':relationship(Child, uselist=False, + 'child':relationship(Child, uselist=False, cascade="all, delete-orphan", backref="parent") }) @@ -1255,14 +1255,14 @@ class BatchInsertsTest(fixtures.MappedTest, testing.AssertsExecutionResults): @classmethod def define_tables(cls, metadata): Table('t', metadata, - Column('id', Integer, primary_key=True, + Column('id', Integer, primary_key=True, test_needs_autoincrement=True), Column('data', String(50)), Column('def_', String(50), server_default='def1') ) def test_batch_interaction(self): - """test batching groups same-structured, primary + """test batching groups same-structured, primary key present statements together. """ @@ -1299,8 +1299,8 @@ class BatchInsertsTest(fixtures.MappedTest, testing.AssertsExecutionResults): ), CompiledSQL( "INSERT INTO t (id, data) VALUES (:id, :data)", - [{'data': 't3', 'id': 3}, - {'data': 't4', 'id': 4}, + [{'data': 't3', 'id': 3}, + {'data': 't4', 'id': 4}, {'data': 't5', 'id': 5}] ), CompiledSQL( @@ -1313,7 +1313,7 @@ class BatchInsertsTest(fixtures.MappedTest, testing.AssertsExecutionResults): ), CompiledSQL( "INSERT INTO t (id, data, def_) VALUES (:id, :data, :def_)", - [{'data': 't9', 'id': 9, 'def_':'def2'}, + [{'data': 't9', 'id': 9, 'def_':'def2'}, {'data': 't10', 'id': 10, 'def_':'def3'}] ), CompiledSQL( diff --git a/test/orm/test_update_delete.py b/test/orm/test_update_delete.py index af23cd1fc..252c1cfa3 100644 --- a/test/orm/test_update_delete.py +++ b/test/orm/test_update_delete.py @@ -12,7 +12,7 @@ class UpdateDeleteTest(fixtures.MappedTest): @classmethod def define_tables(cls, metadata): Table('users', metadata, - Column('id', Integer, primary_key=True, + Column('id', Integer, primary_key=True, test_needs_autoincrement=True), Column('name', String(32)), Column('age', Integer)) @@ -66,13 +66,13 @@ class UpdateDeleteTest(fixtures.MappedTest): (s.query(User).distinct(), "distinct") ): assert_raises_message( - exc.InvalidRequestError, - r"Can't call Query.update\(\) when %s\(\) has been called" % mname, - q.update, + exc.InvalidRequestError, + r"Can't call Query.update\(\) when %s\(\) has been called" % mname, + q.update, {'name':'ed'}) assert_raises_message( - exc.InvalidRequestError, - r"Can't call Query.delete\(\) when %s\(\) has been called" % mname, + exc.InvalidRequestError, + r"Can't call Query.delete\(\) when %s\(\) has been called" % mname, q.delete) @@ -157,7 +157,7 @@ class UpdateDeleteTest(fixtures.MappedTest): assert_raises(exc.InvalidRequestError, sess.query(User). - filter(User.name == select([func.max(User.name)])).delete, + filter(User.name == select([func.max(User.name)])).delete, synchronize_session='evaluate' ) @@ -328,7 +328,7 @@ class UpdateDeleteTest(fixtures.MappedTest): john.name = 'j2' sess.query(User).filter_by(name='j2').\ - update({'age':42}, + update({'age':42}, synchronize_session='evaluate') eq_(john.age, 42) @@ -340,7 +340,7 @@ class UpdateDeleteTest(fixtures.MappedTest): john.name = 'j2' sess.query(User).filter_by(name='j2').\ - update({'age':42}, + update({'age':42}, synchronize_session='fetch') eq_(john.age, 42) @@ -376,10 +376,10 @@ class UpdateDeleteTest(fixtures.MappedTest): sess.expire(john, ['age']) # eval must be before the update. otherwise - # we eval john, age has been expired and doesn't + # we eval john, age has been expired and doesn't # match the new value coming in sess.query(User).filter_by(name='john').filter_by(age=25).\ - update({'name':'j2', 'age':40}, + update({'name':'j2', 'age':40}, synchronize_session='evaluate') eq_(john.name, 'j2') eq_(john.age, 40) @@ -392,7 +392,7 @@ class UpdateDeleteTest(fixtures.MappedTest): sess.expire(john, ['age']) sess.query(User).filter_by(name='john').filter_by(age=25).\ - update({'name':'j2', 'age':40}, + update({'name':'j2', 'age':40}, synchronize_session='fetch') eq_(john.name, 'j2') eq_(john.age, 40) @@ -427,13 +427,13 @@ class UpdateDeleteRelatedTest(fixtures.MappedTest): @classmethod def define_tables(cls, metadata): Table('users', metadata, - Column('id', Integer, primary_key=True, + Column('id', Integer, primary_key=True, test_needs_autoincrement=True), Column('name', String(32)), Column('age', Integer)) Table('documents', metadata, - Column('id', Integer, primary_key=True, + Column('id', Integer, primary_key=True, test_needs_autoincrement=True), Column('user_id', None, ForeignKey('users.id')), Column('title', String(32))) @@ -474,7 +474,7 @@ class UpdateDeleteRelatedTest(fixtures.MappedTest): mapper(User, users) mapper(Document, documents, properties={ - 'user': relationship(User, lazy='joined', + 'user': relationship(User, lazy='joined', backref=backref('documents', lazy='select')) }) @@ -488,7 +488,7 @@ class UpdateDeleteRelatedTest(fixtures.MappedTest): update({'title': Document.title+Document.title}, synchronize_session='fetch') eq_([foo.title, bar.title, baz.title], ['foofoo','barbar', 'baz']) - eq_(sess.query(Document.title).order_by(Document.id).all(), + eq_(sess.query(Document.title).order_by(Document.id).all(), zip(['foofoo','barbar', 'baz'])) def test_update_with_explicit_joinedload(self): @@ -517,7 +517,7 @@ class ExpressionUpdateTest(fixtures.MappedTest): @classmethod def define_tables(cls, metadata): data = Table('data', metadata, - Column('id', Integer, primary_key=True, + Column('id', Integer, primary_key=True, test_needs_autoincrement=True), Column('counter', Integer, nullable=False, default=0) ) diff --git a/test/orm/test_versioning.py b/test/orm/test_versioning.py index accce0372..721bd1286 100644 --- a/test/orm/test_versioning.py +++ b/test/orm/test_versioning.py @@ -51,7 +51,7 @@ class VersioningTest(fixtures.MappedTest): def _fixture(self): Foo, version_table = self.classes.Foo, self.tables.version_table - mapper(Foo, version_table, + mapper(Foo, version_table, version_id_col=version_table.c.version_id) s1 = Session() return s1 @@ -97,7 +97,7 @@ class VersioningTest(fixtures.MappedTest): # Only dialects with a sane rowcount can detect the # StaleDataError if testing.db.dialect.supports_sane_rowcount: - assert_raises_message(sa.orm.exc.StaleDataError, + assert_raises_message(sa.orm.exc.StaleDataError, r"UPDATE statement on table 'version_table' expected " r"to update 1 row\(s\); 0 were matched.", s1.commit), @@ -117,7 +117,7 @@ class VersioningTest(fixtures.MappedTest): if testing.db.dialect.supports_sane_rowcount: assert_raises_message( - sa.orm.exc.StaleDataError, + sa.orm.exc.StaleDataError, r"DELETE statement on table 'version_table' expected " r"to delete 2 row\(s\); 1 were matched.", s1.commit) @@ -128,8 +128,8 @@ class VersioningTest(fixtures.MappedTest): def test_bump_version(self): """test that version number can be bumped. - Ensures that the UPDATE or DELETE is against the - last committed version of version_id_col, not the modified + Ensures that the UPDATE or DELETE is against the + last committed version of version_id_col, not the modified state. """ @@ -177,7 +177,7 @@ class VersioningTest(fixtures.MappedTest): # load, version is wrong assert_raises_message( - sa.orm.exc.StaleDataError, + sa.orm.exc.StaleDataError, r"Instance .* has version id '\d+' which does not " r"match database-loaded version id '\d+'", s1.query(Foo).with_lockmode('read').get, f1s1.id @@ -351,7 +351,7 @@ class RowSwitchTest(fixtures.MappedTest): cls.classes.C, cls.classes.P) - mapper(P, p, version_id_col=p.c.version_id, + mapper(P, p, version_id_col=p.c.version_id, properties={ 'c':relationship(C, uselist=False, cascade='all, delete-orphan') }) @@ -418,7 +418,7 @@ class AlternateGeneratorTest(fixtures.MappedTest): cls.classes.C, cls.classes.P) - mapper(P, p, version_id_col=p.c.version_id, + mapper(P, p, version_id_col=p.c.version_id, version_id_generator=lambda x:make_uuid(), properties={ 'c':relationship(C, uselist=False, cascade='all, delete-orphan') @@ -466,7 +466,7 @@ class AlternateGeneratorTest(fixtures.MappedTest): Session = sessionmaker() - # TODO: not sure this test is + # TODO: not sure this test is # testing exactly what its looking for sess1 = Session() @@ -528,7 +528,7 @@ class InheritanceTwoVersionIdsTest(fixtures.MappedTest): self.tables.base, self.classes.Sub) - mapper(Base, base, + mapper(Base, base, version_id_col=base.c.version_id) mapper(Sub, sub, inherits=Base) @@ -546,7 +546,7 @@ class InheritanceTwoVersionIdsTest(fixtures.MappedTest): self.tables.base, self.classes.Sub) - mapper(Base, base, + mapper(Base, base, version_id_col=base.c.version_id) mapper(Sub, sub, inherits=Base) @@ -568,7 +568,7 @@ class InheritanceTwoVersionIdsTest(fixtures.MappedTest): self.classes.Sub) mapper(Base, base) - mapper(Sub, sub, inherits=Base, + mapper(Sub, sub, inherits=Base, version_id_col=sub.c.version_id) session = Session() @@ -588,7 +588,7 @@ class InheritanceTwoVersionIdsTest(fixtures.MappedTest): self.tables.base, self.classes.Sub) - mapper(Base, base, + mapper(Base, base, version_id_col=base.c.version_id) assert_raises_message( @@ -599,5 +599,5 @@ class InheritanceTwoVersionIdsTest(fixtures.MappedTest): "version_id_col should only be specified on " "the base-most mapper that includes versioning.", mapper, - Sub, sub, inherits=Base, + Sub, sub, inherits=Base, version_id_col=sub.c.version_id) diff --git a/test/perf/stress_all.py b/test/perf/stress_all.py index a19be9579..b5d210eef 100644 --- a/test/perf/stress_all.py +++ b/test/perf/stress_all.py @@ -137,7 +137,7 @@ unicodetest = (Unicode(20, assert_unicode=False), genunicodevalue, if test_types: tests = [booleantest, datetimetest, decimaltest, intervaltest, pickletypetest, typedecoratortest, unicodetest] - for engineurl in ('postgresql://scott:tiger@localhost/test', + for engineurl in ('postgresql://scott:tiger@localhost/test', 'sqlite://', 'mysql://scott:tiger@localhost/test'): print "\n%s\n" % engineurl for datatype, genvalue, kwargs in tests: @@ -156,7 +156,7 @@ if test_methods: getitem_str_results, getitem_fallback_results, getitem_int_results, getitem_long_results, getitem_obj_results, slice_results] - for engineurl in ('postgresql://scott:tiger@localhost/test', + for engineurl in ('postgresql://scott:tiger@localhost/test', 'sqlite://', 'mysql://scott:tiger@localhost/test'): print "\n%s\n" % engineurl test_table = prepare(Unicode(20, assert_unicode=False), diff --git a/test/sql/test_constraints.py b/test/sql/test_constraints.py index fcc6c085e..2869839dc 100644 --- a/test/sql/test_constraints.py +++ b/test/sql/test_constraints.py @@ -194,7 +194,7 @@ class ConstraintTest(fixtures.TestBase, AssertsExecutionResults, AssertsCompiled ('sometable', 'this_name_alsois_long', 'ix_sometable_t_3cf1'), ]: - t1 = Table(tname, MetaData(), + t1 = Table(tname, MetaData(), Column(cname, Integer, index=True), ) ix1 = list(t1.indexes)[0] @@ -213,24 +213,24 @@ class ConstraintTest(fixtures.TestBase, AssertsExecutionResults, AssertsCompiled assert_raises( exc.IdentifierError, schema.CreateIndex(Index( - "this_other_name_is_too_long_for_what_were_doing", + "this_other_name_is_too_long_for_what_were_doing", t1.c.c)).compile, dialect=dialect ) def test_index_declartion_inline(self): - t1 = Table('t1', metadata, + t1 = Table('t1', metadata, Column('x', Integer), Column('y', Integer), Index('foo', 'x', 'y') ) self.assert_compile( - schema.CreateIndex(list(t1.indexes)[0]), + schema.CreateIndex(list(t1.indexes)[0]), "CREATE INDEX foo ON t1 (x, y)" ) def test_index_asserts_cols_standalone(self): - t1 = Table('t1', metadata, + t1 = Table('t1', metadata, Column('x', Integer) ) t2 = Table('t2', metadata, @@ -244,7 +244,7 @@ class ConstraintTest(fixtures.TestBase, AssertsExecutionResults, AssertsCompiled ) def test_index_asserts_cols_inline(self): - t1 = Table('t1', metadata, + t1 = Table('t1', metadata, Column('x', Integer) ) assert_raises_message( @@ -384,7 +384,7 @@ class ConstraintCompilationTest(fixtures.TestBase, AssertsCompiledSQL): def test_multiple(self): m = MetaData() - foo = Table("foo", m, + foo = Table("foo", m, Column('id', Integer, primary_key=True), Column('bar', Integer, primary_key=True) ) @@ -433,11 +433,11 @@ class ConstraintCompilationTest(fixtures.TestBase, AssertsCompiledSQL): m.drop_all(e) e.assert_sql([ - 'CREATE TABLE t (a INTEGER)', - 'CREATE TABLE t2 (a INTEGER, b INTEGER, CONSTRAINT fk_tb FOREIGN KEY(b) REFERENCES t (a))', - 'ALTER TABLE t2 ADD CONSTRAINT fk_ta FOREIGN KEY(a) REFERENCES t (a)', - 'ALTER TABLE t2 DROP CONSTRAINT fk_ta', - 'DROP TABLE t2', + 'CREATE TABLE t (a INTEGER)', + 'CREATE TABLE t2 (a INTEGER, b INTEGER, CONSTRAINT fk_tb FOREIGN KEY(b) REFERENCES t (a))', + 'ALTER TABLE t2 ADD CONSTRAINT fk_ta FOREIGN KEY(a) REFERENCES t (a)', + 'ALTER TABLE t2 DROP CONSTRAINT fk_ta', + 'DROP TABLE t2', 'DROP TABLE t' ]) @@ -456,7 +456,7 @@ class ConstraintCompilationTest(fixtures.TestBase, AssertsCompiledSQL): ) constraint = CheckConstraint('a < b',name="my_test_constraint", - deferrable=True,initially='DEFERRED', + deferrable=True,initially='DEFERRED', table=t) diff --git a/test/sql/test_defaults.py b/test/sql/test_defaults.py index ec08cd28e..7a6c6d009 100644 --- a/test/sql/test_defaults.py +++ b/test/sql/test_defaults.py @@ -305,7 +305,7 @@ class DefaultTest(fixtures.TestBase): def test_no_embed_in_sql(self): """Using a DefaultGenerator, Sequence, DefaultClause - in the columns, where clause of a select, or in the values + in the columns, where clause of a select, or in the values clause of insert, update, raises an informative error""" for const in ( @@ -330,7 +330,7 @@ class DefaultTest(fixtures.TestBase): ) def test_missing_many_param(self): - assert_raises_message(exc.StatementError, + assert_raises_message(exc.StatementError, "A value is required for bind parameter 'col7', in parameter group 1", t.insert().execute, {'col4':7, 'col7':12, 'col8':19}, @@ -558,8 +558,8 @@ class AutoIncrementTest(fixtures.TablesTest): Column('id', Integer(), primary_key=True) ) x = Table('x', m, - Column('id', Integer(), - ForeignKey('y.id'), + Column('id', Integer(), + ForeignKey('y.id'), autoincrement="ignore_fk", primary_key=True) ) assert x._autoincrement_column is x.c.id @@ -570,8 +570,8 @@ class AutoIncrementTest(fixtures.TablesTest): Column('id', Integer(), primary_key=True) ) x = Table('x', m, - Column('id', Integer(), - ForeignKey('y.id'), + Column('id', Integer(), + ForeignKey('y.id'), primary_key=True) ) assert x._autoincrement_column is None @@ -652,7 +652,7 @@ class SequenceExecTest(fixtures.TestBase): self._assert_seq_result(s.execute(testing.db)) def test_explicit_optional(self): - """test dialect executes a Sequence, returns nextval, whether + """test dialect executes a Sequence, returns nextval, whether or not "optional" is set """ s = Sequence("my_sequence", optional=True) @@ -721,7 +721,7 @@ class SequenceExecTest(fixtures.TestBase): @testing.provide_metadata def test_inserted_pk_no_returning(self): - """test inserted_primary_key contains [None] when + """test inserted_primary_key contains [None] when pk_col=next_value(), implicit returning is not used.""" metadata = self.metadata @@ -740,7 +740,7 @@ class SequenceExecTest(fixtures.TestBase): @testing.requires.returning @testing.provide_metadata def test_inserted_pk_implicit_returning(self): - """test inserted_primary_key contains the result when + """test inserted_primary_key contains the result when pk_col=next_value(), when implicit returning is used.""" metadata = self.metadata @@ -762,8 +762,8 @@ class SequenceTest(fixtures.TestBase, testing.AssertsCompiledSQL): @testing.fails_on('firebird', 'no FB support for start/increment') def test_start_increment(self): for seq in ( - Sequence('foo_seq'), - Sequence('foo_seq', start=8), + Sequence('foo_seq'), + Sequence('foo_seq', start=8), Sequence('foo_seq', increment=5)): seq.create(testing.db) try: @@ -782,11 +782,11 @@ class SequenceTest(fixtures.TestBase, testing.AssertsCompiledSQL): return testing.db.dialect.has_sequence(testing.db, name) def test_nextval_render(self): - """test dialect renders the "nextval" construct, + """test dialect renders the "nextval" construct, whether or not "optional" is set """ for s in ( - Sequence("my_seq"), + Sequence("my_seq"), Sequence("my_seq", optional=True)): assert str(s.next_value(). compile(dialect=testing.db.dialect)) in ( @@ -796,7 +796,7 @@ class SequenceTest(fixtures.TestBase, testing.AssertsCompiledSQL): ) def test_nextval_unsupported(self): - """test next_value() used on non-sequence platform + """test next_value() used on non-sequence platform raises NotImplementedError.""" s = Sequence("my_seq") @@ -844,7 +844,7 @@ class SequenceTest(fixtures.TestBase, testing.AssertsCompiledSQL): s1 = Sequence("s1", metadata=metadata) s2 = Sequence("s2", metadata=metadata) s3 = Sequence("s3") - t = Table('t', metadata, + t = Table('t', metadata, Column('c', Integer, s3, primary_key=True)) assert s3.metadata is metadata @@ -1017,7 +1017,7 @@ class SpecialTypePKTest(fixtures.TestBase): class ServerDefaultsOnPKTest(fixtures.TestBase): @testing.provide_metadata def test_string_default_none_on_insert(self): - """Test that without implicit returning, we return None for + """Test that without implicit returning, we return None for a string server default. That is, we don't want to attempt to pre-execute "server_default" @@ -1027,7 +1027,7 @@ class ServerDefaultsOnPKTest(fixtures.TestBase): """ metadata = self.metadata - t = Table('x', metadata, + t = Table('x', metadata, Column('y', String(10), server_default='key_one', primary_key=True), Column('data', String(10)), implicit_returning=False @@ -1046,7 +1046,7 @@ class ServerDefaultsOnPKTest(fixtures.TestBase): """With implicit_returning, we get a string PK default back no problem.""" metadata = self.metadata - t = Table('x', metadata, + t = Table('x', metadata, Column('y', String(10), server_default='key_one', primary_key=True), Column('data', String(10)) ) @@ -1061,8 +1061,8 @@ class ServerDefaultsOnPKTest(fixtures.TestBase): @testing.provide_metadata def test_int_default_none_on_insert(self): metadata = self.metadata - t = Table('x', metadata, - Column('y', Integer, + t = Table('x', metadata, + Column('y', Integer, server_default='5', primary_key=True), Column('data', String(10)), implicit_returning=False @@ -1084,8 +1084,8 @@ class ServerDefaultsOnPKTest(fixtures.TestBase): @testing.provide_metadata def test_autoincrement_reflected_from_server_default(self): metadata = self.metadata - t = Table('x', metadata, - Column('y', Integer, + t = Table('x', metadata, + Column('y', Integer, server_default='5', primary_key=True), Column('data', String(10)), implicit_returning=False @@ -1100,8 +1100,8 @@ class ServerDefaultsOnPKTest(fixtures.TestBase): @testing.provide_metadata def test_int_default_none_on_insert_reflected(self): metadata = self.metadata - t = Table('x', metadata, - Column('y', Integer, + t = Table('x', metadata, + Column('y', Integer, server_default='5', primary_key=True), Column('data', String(10)), implicit_returning=False @@ -1128,8 +1128,8 @@ class ServerDefaultsOnPKTest(fixtures.TestBase): @testing.provide_metadata def test_int_default_on_insert_with_returning(self): metadata = self.metadata - t = Table('x', metadata, - Column('y', Integer, + t = Table('x', metadata, + Column('y', Integer, server_default='5', primary_key=True), Column('data', String(10)) ) diff --git a/test/sql/test_functions.py b/test/sql/test_functions.py index 961845bac..2f9c6f908 100644 --- a/test/sql/test_functions.py +++ b/test/sql/test_functions.py @@ -36,13 +36,13 @@ class CompileTest(fixtures.TestBase, AssertsCompiledSQL): GenericFunction.__init__(self, args=[arg], **kwargs) self.assert_compile( - fake_func('foo'), - "fake_func(%s)" % - bindtemplate % {'name':'param_1', 'position':1}, + fake_func('foo'), + "fake_func(%s)" % + bindtemplate % {'name':'param_1', 'position':1}, dialect=dialect) def test_use_labels(self): - self.assert_compile(select([func.foo()], use_labels=True), + self.assert_compile(select([func.foo()], use_labels=True), "SELECT foo() AS foo_1" ) def test_underscores(self): @@ -105,12 +105,12 @@ class CompileTest(fixtures.TestBase, AssertsCompiledSQL): for fn in [func.coalesce, func.max, func.min, func.sum]: for args, type_ in [ - ((datetime.date(2007, 10, 5), + ((datetime.date(2007, 10, 5), datetime.date(2005, 10, 15)), sqltypes.Date), ((3, 5), sqltypes.Integer), ((decimal.Decimal(3), decimal.Decimal(5)), sqltypes.Numeric), (("foo", "bar"), sqltypes.String), - ((datetime.datetime(2007, 10, 5, 8, 3, 34), + ((datetime.datetime(2007, 10, 5, 8, 3, 34), datetime.datetime(2005, 10, 15, 14, 45, 33)), sqltypes.DateTime) ]: assert isinstance(fn(*args).type, type_), "%s / %s" % (fn(), type_) @@ -149,7 +149,7 @@ class CompileTest(fixtures.TestBase, AssertsCompiledSQL): self.assert_compile(func.lala.hoho(7), "lala.hoho(:hoho_1)") # test None becomes NULL - self.assert_compile(func.my_func(1,2,None,3), + self.assert_compile(func.my_func(1,2,None,3), "my_func(:my_func_1, :my_func_2, NULL, :my_func_3)") # test pickling diff --git a/test/sql/test_generative.py b/test/sql/test_generative.py index 29b7cd482..b78559960 100644 --- a/test/sql/test_generative.py +++ b/test/sql/test_generative.py @@ -8,7 +8,7 @@ from sqlalchemy.sql import util as sql_util from test.lib.testing import eq_, ne_, assert_raises class TraversalTest(fixtures.TestBase, AssertsExecutionResults): - """test ClauseVisitor's traversal, particularly its + """test ClauseVisitor's traversal, particularly its ability to copy and modify a ClauseElement in place.""" @classmethod @@ -16,7 +16,7 @@ class TraversalTest(fixtures.TestBase, AssertsExecutionResults): global A, B # establish two ficticious ClauseElements. - # define deep equality semantics as well as deep + # define deep equality semantics as well as deep # identity semantics. class A(ClauseElement): __visit_name__ = 'a' @@ -79,7 +79,7 @@ class TraversalTest(fixtures.TestBase, AssertsExecutionResults): a1 = A("expr1") struct = B(a1, A("expr2"), B(A("expr1b"), A("expr2b")), A("expr3")) struct2 = B(a1, A("expr2"), B(A("expr1b"), A("expr2b")), A("expr3")) - struct3 = B(a1, A("expr2"), B(A("expr1b"), + struct3 = B(a1, A("expr2"), B(A("expr1b"), A("expr2bmodified")), A("expr3")) assert a1.is_other(a1) @@ -90,7 +90,7 @@ class TraversalTest(fixtures.TestBase, AssertsExecutionResults): assert not struct.is_other(struct3) def test_clone(self): - struct = B(A("expr1"), A("expr2"), B(A("expr1b"), + struct = B(A("expr1"), A("expr2"), B(A("expr1b"), A("expr2b")), A("expr3")) class Vis(CloningVisitor): @@ -105,7 +105,7 @@ class TraversalTest(fixtures.TestBase, AssertsExecutionResults): assert not struct.is_other(s2) def test_no_clone(self): - struct = B(A("expr1"), A("expr2"), B(A("expr1b"), + struct = B(A("expr1"), A("expr2"), B(A("expr1b"), A("expr2b")), A("expr3")) class Vis(ClauseVisitor): @@ -120,11 +120,11 @@ class TraversalTest(fixtures.TestBase, AssertsExecutionResults): assert struct.is_other(s2) def test_change_in_place(self): - struct = B(A("expr1"), A("expr2"), B(A("expr1b"), + struct = B(A("expr1"), A("expr2"), B(A("expr1b"), A("expr2b")), A("expr3")) - struct2 = B(A("expr1"), A("expr2modified"), B(A("expr1b"), + struct2 = B(A("expr1"), A("expr2modified"), B(A("expr1b"), A("expr2b")), A("expr3")) - struct3 = B(A("expr1"), A("expr2"), B(A("expr1b"), + struct3 = B(A("expr1"), A("expr2"), B(A("expr1b"), A("expr2bmodified")), A("expr3")) class Vis(CloningVisitor): @@ -280,7 +280,7 @@ class ClauseTest(fixtures.TestBase, AssertsCompiledSQL): column("col2"), column("col3"), ) - t3 = Table('table3', MetaData(), + t3 = Table('table3', MetaData(), Column('col1', Integer), Column('col2', Integer) ) @@ -294,7 +294,7 @@ class ClauseTest(fixtures.TestBase, AssertsCompiledSQL): f = t.c.col1 * 5 - self.assert_compile(select([f]), + self.assert_compile(select([f]), "SELECT t1.col1 * :col1_1 AS anon_1 FROM t1") f.anon_label @@ -302,7 +302,7 @@ class ClauseTest(fixtures.TestBase, AssertsCompiledSQL): a = t.alias() f = sql_util.ClauseAdapter(a).traverse(f) - self.assert_compile(select([f]), + self.assert_compile(select([f]), "SELECT t1_1.col1 * :col1_1 AS anon_1 FROM t1 AS t1_1") def test_join(self): @@ -323,7 +323,7 @@ class ClauseTest(fixtures.TestBase, AssertsCompiledSQL): aliased = t1.select().alias() aliased2 = t1.alias() - + adapter = sql_util.ColumnAdapter(aliased) f = select([ @@ -333,7 +333,7 @@ class ClauseTest(fixtures.TestBase, AssertsCompiledSQL): s = select([aliased2]).select_from(aliased) eq_(str(s), str(f)) - + f = select([ adapter.columns[func.count(aliased2.c.col1)] ]).select_from(aliased) @@ -352,7 +352,7 @@ class ClauseTest(fixtures.TestBase, AssertsCompiledSQL): # fixed by [ticket:2419]. the inside columns # on aliased3 have _is_clone_of pointers to those of - # aliased2. corresponding_column checks these + # aliased2. corresponding_column checks these # now. adapter = sql_util.ColumnAdapter(aliased1) f1 = select([ @@ -376,7 +376,7 @@ class ClauseTest(fixtures.TestBase, AssertsCompiledSQL): aliased3 = cloned_traverse(aliased2, {}, {}) # also fixed by [ticket:2419]. When we look at the - # *outside* columns of aliased3, they previously did not + # *outside* columns of aliased3, they previously did not # have an _is_clone_of pointer. But we now modified _make_proxy # to assign this. adapter = sql_util.ColumnAdapter(aliased1) @@ -401,7 +401,7 @@ class ClauseTest(fixtures.TestBase, AssertsCompiledSQL): aliased3 = cloned_traverse(aliased2, {}, {}) # also fixed by [ticket:2419]. When we look at the - # *outside* columns of aliased3, they previously did not + # *outside* columns of aliased3, they previously did not # have an _is_clone_of pointer. But we now modified _make_proxy # to assign this. adapter = sql_util.ColumnAdapter(aliased1) @@ -517,14 +517,14 @@ class ClauseTest(fixtures.TestBase, AssertsCompiledSQL): assert sql_util.ClauseAdapter(u).traverse(t1) is u def test_binds(self): - """test that unique bindparams change their name upon clone() + """test that unique bindparams change their name upon clone() to prevent conflicts""" s = select([t1], t1.c.col1==bindparam(None, unique=True)).alias() s2 = CloningVisitor().traverse(s).alias() s3 = select([s], s.c.col2==s2.c.col2) - self.assert_compile(s3, + self.assert_compile(s3, "SELECT anon_1.col1, anon_1.col2, anon_1.col3 FROM " "(SELECT table1.col1 AS col1, table1.col2 AS col2, " "table1.col3 AS col3 FROM table1 WHERE table1.col1 = :param_1) " @@ -536,7 +536,7 @@ class ClauseTest(fixtures.TestBase, AssertsCompiledSQL): s = select([t1], t1.c.col1==4).alias() s2 = CloningVisitor().traverse(s).alias() s3 = select([s], s.c.col2==s2.c.col2) - self.assert_compile(s3, + self.assert_compile(s3, "SELECT anon_1.col1, anon_1.col2, anon_1.col3 FROM " "(SELECT table1.col1 AS col1, table1.col2 AS col2, " "table1.col3 AS col3 FROM table1 WHERE table1.col1 = :col1_1) " @@ -547,14 +547,14 @@ class ClauseTest(fixtures.TestBase, AssertsCompiledSQL): def test_extract(self): s = select([extract('foo', t1.c.col1).label('col1')]) - self.assert_compile(s, + self.assert_compile(s, "SELECT EXTRACT(foo FROM table1.col1) AS col1 FROM table1") s2 = CloningVisitor().traverse(s).alias() s3 = select([s2.c.col1]) - self.assert_compile(s, + self.assert_compile(s, "SELECT EXTRACT(foo FROM table1.col1) AS col1 FROM table1") - self.assert_compile(s3, + self.assert_compile(s3, "SELECT anon_1.col1 FROM (SELECT EXTRACT(foo FROM " "table1.col1) AS col1 FROM table1) AS anon_1") @@ -562,8 +562,8 @@ class ClauseTest(fixtures.TestBase, AssertsCompiledSQL): @testing.emits_warning('.*replaced by another column with the same key') def test_alias(self): subq = t2.select().alias('subq') - s = select([t1.c.col1, subq.c.col1], - from_obj=[t1, subq, + s = select([t1.c.col1, subq.c.col1], + from_obj=[t1, subq, t1.join(subq, t1.c.col1==subq.c.col2)] ) orig = str(s) @@ -580,21 +580,21 @@ class ClauseTest(fixtures.TestBase, AssertsCompiledSQL): assert orig == str(s) == str(s3) == str(s4) subq = subq.alias('subq') - s = select([t1.c.col1, subq.c.col1], - from_obj=[t1, subq, + s = select([t1.c.col1, subq.c.col1], + from_obj=[t1, subq, t1.join(subq, t1.c.col1==subq.c.col2)] ) s5 = CloningVisitor().traverse(s) assert orig == str(s) == str(s5) def test_correlated_select(self): - s = select(['*'], t1.c.col1==t2.c.col1, + s = select(['*'], t1.c.col1==t2.c.col1, from_obj=[t1, t2]).correlate(t2) class Vis(CloningVisitor): def visit_select(self, select): select.append_whereclause(t1.c.col2==7) - self.assert_compile(Vis().traverse(s), + self.assert_compile(Vis().traverse(s), "SELECT * FROM table1 WHERE table1.col1 = table2.col1 " "AND table1.col2 = :col2_1") @@ -851,8 +851,8 @@ class ClauseAdapterTest(fixtures.TestBase, AssertsCompiledSQL): m = MetaData() a=Table( 'a',m, Column( 'id', Integer, primary_key=True), - Column( 'xxx_id', Integer, - ForeignKey( 'a.id', name='adf',use_alter=True ) + Column( 'xxx_id', Integer, + ForeignKey( 'a.id', name='adf',use_alter=True ) ) ) @@ -887,7 +887,7 @@ class ClauseAdapterTest(fixtures.TestBase, AssertsCompiledSQL): alias = select([a]).select_from(a.join(b, a.c.x==b.c.x)).alias() - # two levels of indirection from c.x->b.x->a.x, requires recursive + # two levels of indirection from c.x->b.x->a.x, requires recursive # corresponding_column call adapt = sql_util.ClauseAdapter(alias, equivalents={b.c.x: set([a.c.x]), c.c.x: set([b.c.x])}) @@ -1267,7 +1267,7 @@ class SelectTest(fixtures.TestBase, AssertsCompiledSQL): assert_raises( exc.ArgumentError, - select().execution_options, + select().execution_options, isolation_level='READ_COMMITTED' ) diff --git a/test/sql/test_labels.py b/test/sql/test_labels.py index 7c65a1d01..c814a0130 100644 --- a/test/sql/test_labels.py +++ b/test/sql/test_labels.py @@ -27,14 +27,14 @@ class LongLabelsTest(fixtures.TablesTest, AssertsCompiledSQL): def define_tables(cls, metadata): table1 = Table("some_large_named_table", metadata, Column("this_is_the_primarykey_column", Integer, - primary_key=True, + primary_key=True, test_needs_autoincrement=True), Column("this_is_the_data_column", String(30)) ) table2 = Table("table_with_exactly_29_characs", metadata, Column("this_is_the_primarykey_column", Integer, - primary_key=True, + primary_key=True, test_needs_autoincrement=True), Column("this_is_the_data_column", String(30)) ) @@ -46,13 +46,13 @@ class LongLabelsTest(fixtures.TablesTest, AssertsCompiledSQL): table1 = cls.tables.table1 table2 = cls.tables.table2 for data in [ - {"this_is_the_primarykey_column":1, + {"this_is_the_primarykey_column":1, "this_is_the_data_column":"data1"}, - {"this_is_the_primarykey_column":2, + {"this_is_the_primarykey_column":2, "this_is_the_data_column":"data2"}, - {"this_is_the_primarykey_column":3, + {"this_is_the_primarykey_column":3, "this_is_the_data_column":"data3"}, - {"this_is_the_primarykey_column":4, + {"this_is_the_primarykey_column":4, "this_is_the_data_column":"data4"} ]: testing.db.execute( @@ -61,7 +61,7 @@ class LongLabelsTest(fixtures.TablesTest, AssertsCompiledSQL): ) testing.db.execute( table2.insert(), - {"this_is_the_primary_key_column":1, + {"this_is_the_primary_key_column":1, "this_is_the_data_column":"data"} ) @@ -78,7 +78,7 @@ class LongLabelsTest(fixtures.TablesTest, AssertsCompiledSQL): def test_too_long_name_disallowed(self): m = MetaData(testing.db) - t1 = Table("this_name_is_too_long_for_what_were_doing_in_this_test", + t1 = Table("this_name_is_too_long_for_what_were_doing_in_this_test", m, Column('foo', Integer)) assert_raises(exceptions.IdentifierError, m.create_all) assert_raises(exceptions.IdentifierError, m.drop_all) @@ -87,11 +87,11 @@ class LongLabelsTest(fixtures.TablesTest, AssertsCompiledSQL): def test_basic_result(self): table1 = self.tables.table1 - s = table1.select(use_labels=True, + s = table1.select(use_labels=True, order_by=[table1.c.this_is_the_primarykey_column]) result = [ - (row[table1.c.this_is_the_primarykey_column], + (row[table1.c.this_is_the_primarykey_column], row[table1.c.this_is_the_data_column]) for row in testing.db.execute(s) ] @@ -104,18 +104,18 @@ class LongLabelsTest(fixtures.TablesTest, AssertsCompiledSQL): def test_result_limit(self): table1 = self.tables.table1 - # some dialects such as oracle (and possibly ms-sql + # some dialects such as oracle (and possibly ms-sql # in a future version) # generate a subquery for limits/offsets. - # ensure that the generated result map corresponds + # ensure that the generated result map corresponds # to the selected table, not # the select query - s = table1.select(use_labels=True, + s = table1.select(use_labels=True, order_by=[table1.c.this_is_the_primarykey_column]).\ limit(2) result = [ - (row[table1.c.this_is_the_primarykey_column], + (row[table1.c.this_is_the_primarykey_column], row[table1.c.this_is_the_data_column]) for row in testing.db.execute(s) ] @@ -127,12 +127,12 @@ class LongLabelsTest(fixtures.TablesTest, AssertsCompiledSQL): @testing.requires.offset def test_result_limit_offset(self): table1 = self.tables.table1 - s = table1.select(use_labels=True, + s = table1.select(use_labels=True, order_by=[table1.c.this_is_the_primarykey_column]).\ limit(2).offset(1) result = [ - (row[table1.c.this_is_the_primarykey_column], + (row[table1.c.this_is_the_primarykey_column], row[table1.c.this_is_the_data_column]) for row in testing.db.execute(s) ] @@ -170,7 +170,7 @@ class LongLabelsTest(fixtures.TablesTest, AssertsCompiledSQL): dialect.max_identifier_length = IDENT_LENGTH self.assert_compile( select([table1, ta]).select_from( - table1.join(ta, + table1.join(ta, table1.c.this_is_the_data_column== ta.c.this_is_the_data_column)).\ where(ta.c.this_is_the_data_column=='data3'), @@ -210,13 +210,13 @@ class LongLabelsTest(fixtures.TablesTest, AssertsCompiledSQL): @testing.provide_metadata def test_insert_no_pk(self): t = Table("some_other_large_named_table", self.metadata, - Column("this_is_the_primarykey_column", Integer, - Sequence("this_is_some_large_seq"), + Column("this_is_the_primarykey_column", Integer, + Sequence("this_is_some_large_seq"), primary_key=True), Column("this_is_the_data_column", String(30)) ) t.create(testing.db, checkfirst=True) - testing.db.execute(t.insert(), + testing.db.execute(t.insert(), **{"this_is_the_data_column":"data1"}) @testing.requires.subqueries @@ -238,7 +238,7 @@ class LongLabelsTest(fixtures.TablesTest, AssertsCompiledSQL): q = table1.select(table1.c.this_is_the_primarykey_column == 4).alias() x = select([q], use_labels=True) - self.assert_compile(x, + self.assert_compile(x, "SELECT anon_1.this_is_the_primarykey_column AS " "anon_1_this_is_the_prim_1, anon_1.this_is_the_data_column " "AS anon_1_this_is_the_data_2 " @@ -249,7 +249,7 @@ class LongLabelsTest(fixtures.TablesTest, AssertsCompiledSQL): "AS this_is_the_data_column " "FROM some_large_named_table " "WHERE some_large_named_table.this_is_the_primarykey_column " - "= :this_is_the_primarykey__1) AS anon_1", + "= :this_is_the_primarykey__1) AS anon_1", dialect=compile_dialect) eq_( @@ -264,13 +264,13 @@ class LongLabelsTest(fixtures.TablesTest, AssertsCompiledSQL): x = select([q]) compile_dialect = default.DefaultDialect(label_length=10) - self.assert_compile(x, + self.assert_compile(x, "SELECT foo.this_1, foo.this_2 FROM " "(SELECT some_large_named_table." "this_is_the_primarykey_column AS this_1, " "some_large_named_table.this_is_the_data_column AS this_2 " "FROM some_large_named_table WHERE " - "some_large_named_table.this_is_the_primarykey_column = :this_1) AS foo", + "some_large_named_table.this_is_the_primarykey_column = :this_1) AS foo", dialect=compile_dialect) compile_dialect = default.DefaultDialect(label_length=4) @@ -278,19 +278,19 @@ class LongLabelsTest(fixtures.TablesTest, AssertsCompiledSQL): "(SELECT some_large_named_table.this_is_the_primarykey_column " "AS _1, some_large_named_table.this_is_the_data_column AS _2 " "FROM some_large_named_table WHERE " - "some_large_named_table.this_is_the_primarykey_column = :_1) AS foo", + "some_large_named_table.this_is_the_primarykey_column = :_1) AS foo", dialect=compile_dialect) q = table1.select(table1.c.this_is_the_primarykey_column == 4).alias() x = select([q], use_labels=True) compile_dialect = default.DefaultDialect(label_length=10) - self.assert_compile(x, + self.assert_compile(x, "SELECT anon_1.this_2 AS anon_1, anon_1.this_4 AS anon_3 FROM " "(SELECT some_large_named_table.this_is_the_primarykey_column " "AS this_2, some_large_named_table.this_is_the_data_column AS this_4 " "FROM some_large_named_table WHERE " - "some_large_named_table.this_is_the_primarykey_column = :this_1) AS anon_1", + "some_large_named_table.this_is_the_primarykey_column = :this_1) AS anon_1", dialect=compile_dialect) compile_dialect = default.DefaultDialect(label_length=4) @@ -298,7 +298,7 @@ class LongLabelsTest(fixtures.TablesTest, AssertsCompiledSQL): "(SELECT some_large_named_table.this_is_the_primarykey_column " "AS _2, some_large_named_table.this_is_the_data_column AS _4 " "FROM some_large_named_table WHERE " - "some_large_named_table.this_is_the_primarykey_column = :_1) AS _1", + "some_large_named_table.this_is_the_primarykey_column = :_1) AS _1", dialect=compile_dialect) def test_adjustable_result_schema_column(self): @@ -321,7 +321,7 @@ class LongLabelsTest(fixtures.TablesTest, AssertsCompiledSQL): def test_adjustable_result_lightweight_column(self): - table1 = table("some_large_named_table", + table1 = table("some_large_named_table", column("this_is_the_primarykey_column"), column("this_is_the_data_column") ) diff --git a/test/sql/test_metadata.py b/test/sql/test_metadata.py index ecbf8ad75..3e9f87fe7 100644 --- a/test/sql/test_metadata.py +++ b/test/sql/test_metadata.py @@ -19,7 +19,7 @@ from test.lib.testing import eq_ class MetaDataTest(fixtures.TestBase, ComparesTables): def test_metadata_connect(self): metadata = MetaData() - t1 = Table('table1', metadata, + t1 = Table('table1', metadata, Column('col1', Integer, primary_key=True), Column('col2', String(20))) metadata.bind = testing.db @@ -58,7 +58,7 @@ class MetaDataTest(fixtures.TestBase, ComparesTables): Column('bar', Integer(), info={'foo':'bar'}), ]: c2 = col.copy() - for attr in ('name', 'type', 'nullable', + for attr in ('name', 'type', 'nullable', 'primary_key', 'key', 'unique', 'info', 'doc'): eq_(getattr(col, attr), getattr(c2, attr)) @@ -148,14 +148,14 @@ class MetaDataTest(fixtures.TestBase, ComparesTables): @testing.provide_metadata def test_dupe_tables(self): metadata = self.metadata - t1 = Table('table1', metadata, + t1 = Table('table1', metadata, Column('col1', Integer, primary_key=True), Column('col2', String(20))) metadata.create_all() t1 = Table('table1', metadata, autoload=True) def go(): - t2 = Table('table1', metadata, + t2 = Table('table1', metadata, Column('col1', Integer, primary_key=True), Column('col2', String(20))) assert_raises_message( @@ -173,11 +173,11 @@ class MetaDataTest(fixtures.TestBase, ComparesTables): m = MetaData() t1 = Table('t', m, c1, c2) - kw = dict(onupdate="X", + kw = dict(onupdate="X", ondelete="Y", use_alter=True, name='f1', deferrable="Z", initially="Q", link_to_name=True) - fk1 = ForeignKey(c1, **kw) + fk1 = ForeignKey(c1, **kw) fk2 = ForeignKeyConstraint((c1,), (c2,), **kw) t1.append_constraint(fk2) @@ -190,10 +190,10 @@ class MetaDataTest(fixtures.TestBase, ComparesTables): def test_check_constraint_copy(self): r = lambda x: x - c = CheckConstraint("foo bar", - name='name', - initially=True, - deferrable=True, + c = CheckConstraint("foo bar", + name='name', + initially=True, + deferrable=True, _create_rule = r) c2 = c.copy() eq_(c2.name, 'name') @@ -273,7 +273,7 @@ class MetaDataTest(fixtures.TestBase, ComparesTables): table2 = Table('othertable', meta, Column('id', Integer, Sequence('foo_seq'), primary_key=True), - Column('myid', Integer, + Column('myid', Integer, ForeignKey('mytable.myid'), ), test_needs_fk=True, @@ -359,7 +359,7 @@ class MetaDataTest(fixtures.TestBase, ComparesTables): m2 = pickle.loads(pickle.dumps(m1)) s2 = Sequence("x_seq") - t2 = Table('a', m2, + t2 = Table('a', m2, Column('id',Integer,primary_key=True), Column('x', Integer, s2), extend_existing=True) @@ -373,7 +373,7 @@ class MetaDataTest(fixtures.TestBase, ComparesTables): m1 = MetaData() s1 = Sequence("x_seq") - t = Table('a', m1, + t = Table('a', m1, Column('x', Integer, s1) ) assert m1._sequences['x_seq'] is s1 @@ -601,9 +601,9 @@ class MetaDataTest(fixtures.TestBase, ComparesTables): table_c = table.tometadata(meta2, schema=None) table2_c = table2.tometadata(meta2, schema=None) - eq_(str(table_c.join(table2_c).onclause), + eq_(str(table_c.join(table2_c).onclause), str(table_c.c.myid == table2_c.c.myid)) - eq_(str(table_c.join(table2_c).onclause), + eq_(str(table_c.join(table2_c).onclause), "someschema.mytable.myid = someschema.othertable.myid") def test_tometadata_strip_schema(self): @@ -644,21 +644,21 @@ class MetaDataTest(fixtures.TestBase, ComparesTables): ck = schema.CheckConstraint("x > y", name="someconstraint") for const, exp in ( - (Sequence("my_seq"), + (Sequence("my_seq"), "Sequence('my_seq')"), - (Sequence("my_seq", start=5), + (Sequence("my_seq", start=5), "Sequence('my_seq', start=5)"), - (Column("foo", Integer), + (Column("foo", Integer), "Column('foo', Integer(), table=None)"), - (Table("bar", MetaData(), Column("x", String)), + (Table("bar", MetaData(), Column("x", String)), "Table('bar', MetaData(bind=None), " "Column('x', String(), table=<bar>), schema=None)"), - (schema.DefaultGenerator(for_update=True), + (schema.DefaultGenerator(for_update=True), "DefaultGenerator(for_update=True)"), (schema.Index("bar", "c"), "Index('bar')"), (i1, "Index('bar', Column('x', Integer(), table=<foo>))"), (schema.FetchedValue(), "FetchedValue()"), - (ck, + (ck, "CheckConstraint(" "%s" ", name='someconstraint')" % repr(ck.sqltext)), @@ -675,7 +675,7 @@ class TableTest(fixtures.TestBase, AssertsCompiledSQL): prefixes = ["TEMPORARY"]) self.assert_compile( - schema.CreateTable(table1), + schema.CreateTable(table1), "CREATE TEMPORARY TABLE temporary_table_1 (col1 INTEGER)" ) @@ -683,7 +683,7 @@ class TableTest(fixtures.TestBase, AssertsCompiledSQL): Column("col1", Integer), prefixes = ["VIRTUAL"]) self.assert_compile( - schema.CreateTable(table2), + schema.CreateTable(table2), "CREATE VIRTUAL TABLE temporary_table_2 (col1 INTEGER)" ) @@ -741,7 +741,7 @@ class SchemaTest(fixtures.TestBase, AssertsCompiledSQL): def test_default_schema_metadata_fk_alt_remote(self): m = MetaData(schema="foo") t1 = Table('t1', m, Column('x', Integer)) - t2 = Table('t2', m, Column('x', Integer, ForeignKey('t1.x')), + t2 = Table('t2', m, Column('x', Integer, ForeignKey('t1.x')), schema="bar") assert t2.c.x.references(t1.c.x) @@ -797,8 +797,8 @@ class SchemaTest(fixtures.TestBase, AssertsCompiledSQL): class UseExistingTest(fixtures.TablesTest): @classmethod def define_tables(cls, metadata): - Table('users', metadata, - Column('id', Integer, primary_key=True), + Table('users', metadata, + Column('id', Integer, primary_key=True), Column('name', String(30))) def _useexisting_fixture(self): @@ -836,7 +836,7 @@ class UseExistingTest(fixtures.TablesTest): meta2 = self._useexisting_fixture() assert_raises( exc.ArgumentError, - Table, 'users', meta2, keep_existing=True, + Table, 'users', meta2, keep_existing=True, extend_existing=True ) @@ -845,13 +845,13 @@ class UseExistingTest(fixtures.TablesTest): meta2 = self._useexisting_fixture() assert_raises( exc.ArgumentError, - Table, 'users', meta2, useexisting=True, + Table, 'users', meta2, useexisting=True, extend_existing=True ) def test_keep_existing_no_dupe_constraints(self): meta2 = self._notexisting_fixture() - users = Table('users', meta2, + users = Table('users', meta2, Column('id', Integer), Column('name', Unicode), UniqueConstraint('name'), @@ -861,7 +861,7 @@ class UseExistingTest(fixtures.TablesTest): assert 'id' in users.c eq_(len(users.constraints), 2) - u2 = Table('users', meta2, + u2 = Table('users', meta2, Column('id', Integer), Column('name', Unicode), UniqueConstraint('name'), @@ -871,7 +871,7 @@ class UseExistingTest(fixtures.TablesTest): def test_extend_existing_dupes_constraints(self): meta2 = self._notexisting_fixture() - users = Table('users', meta2, + users = Table('users', meta2, Column('id', Integer), Column('name', Unicode), UniqueConstraint('name'), @@ -881,7 +881,7 @@ class UseExistingTest(fixtures.TablesTest): assert 'id' in users.c eq_(len(users.constraints), 2) - u2 = Table('users', meta2, + u2 = Table('users', meta2, Column('id', Integer), Column('name', Unicode), UniqueConstraint('name'), @@ -904,7 +904,7 @@ class UseExistingTest(fixtures.TablesTest): def test_keep_existing_add_column(self): meta2 = self._useexisting_fixture() - users = Table('users', meta2, + users = Table('users', meta2, Column('foo', Integer), autoload=True, keep_existing=True) @@ -918,14 +918,14 @@ class UseExistingTest(fixtures.TablesTest): def test_keep_existing_quote_no_orig(self): meta2 = self._notexisting_fixture() - users = Table('users', meta2, quote=True, + users = Table('users', meta2, quote=True, autoload=True, keep_existing=True) assert users.quote def test_keep_existing_add_column_no_orig(self): meta2 = self._notexisting_fixture() - users = Table('users', meta2, + users = Table('users', meta2, Column('foo', Integer), autoload=True, keep_existing=True) @@ -939,13 +939,13 @@ class UseExistingTest(fixtures.TablesTest): def test_keep_existing_quote_no_reflection(self): meta2 = self._useexisting_fixture() - users = Table('users', meta2, quote=True, + users = Table('users', meta2, quote=True, keep_existing=True) assert not users.quote def test_keep_existing_add_column_no_reflection(self): meta2 = self._useexisting_fixture() - users = Table('users', meta2, + users = Table('users', meta2, Column('foo', Integer), keep_existing=True) assert "foo" not in users.c @@ -964,7 +964,7 @@ class UseExistingTest(fixtures.TablesTest): def test_extend_existing_add_column(self): meta2 = self._useexisting_fixture() - users = Table('users', meta2, + users = Table('users', meta2, Column('foo', Integer), autoload=True, extend_existing=True) @@ -978,14 +978,14 @@ class UseExistingTest(fixtures.TablesTest): def test_extend_existing_quote_no_orig(self): meta2 = self._notexisting_fixture() - users = Table('users', meta2, quote=True, + users = Table('users', meta2, quote=True, autoload=True, extend_existing=True) assert users.quote def test_extend_existing_add_column_no_orig(self): meta2 = self._notexisting_fixture() - users = Table('users', meta2, + users = Table('users', meta2, Column('foo', Integer), autoload=True, extend_existing=True) @@ -999,13 +999,13 @@ class UseExistingTest(fixtures.TablesTest): def test_extend_existing_quote_no_reflection(self): meta2 = self._useexisting_fixture() - users = Table('users', meta2, quote=True, + users = Table('users', meta2, quote=True, extend_existing=True) assert users.quote def test_extend_existing_add_column_no_reflection(self): meta2 = self._useexisting_fixture() - users = Table('users', meta2, + users = Table('users', meta2, Column('foo', Integer), extend_existing=True) assert "foo" in users.c @@ -1014,16 +1014,16 @@ class ConstraintTest(fixtures.TestBase): def _single_fixture(self): m = MetaData() - t1 = Table('t1', m, + t1 = Table('t1', m, Column('a', Integer), Column('b', Integer) ) - t2 = Table('t2', m, + t2 = Table('t2', m, Column('a', Integer, ForeignKey('t1.a')) ) - t3 = Table('t3', m, + t3 = Table('t3', m, Column('a', Integer) ) return t1, t2, t3 @@ -1090,7 +1090,7 @@ class ColumnDefinitionTest(AssertsCompiledSQL, fixtures.TestBase): c = Column(Integer) assert_raises_message( - exc.ArgumentError, + exc.ArgumentError, "Column must be constructed with a non-blank name or assign a " "non-blank .name ", Table, 't', MetaData(), c) @@ -1099,7 +1099,7 @@ class ColumnDefinitionTest(AssertsCompiledSQL, fixtures.TestBase): c = Column('', Integer) assert_raises_message( - exc.ArgumentError, + exc.ArgumentError, "Column must be constructed with a non-blank name or assign a " "non-blank .name ", Table, 't', MetaData(), c) @@ -1109,7 +1109,7 @@ class ColumnDefinitionTest(AssertsCompiledSQL, fixtures.TestBase): t = Table('t', MetaData(), c) assert_raises_message( - exc.ArgumentError, + exc.ArgumentError, "Column object already assigned to Table 't'", Table, 'q', MetaData(), c) @@ -1335,7 +1335,7 @@ class CatchAllEventsTest(fixtures.TestBase): event.listen(schema.SchemaItem, "after_parent_attach", after_attach) m = MetaData() - t1 = Table('t1', m, + t1 = Table('t1', m, Column('id', Integer, Sequence('foo_id'), primary_key=True), Column('bar', String, ForeignKey('t2.id')) ) @@ -1375,7 +1375,7 @@ class CatchAllEventsTest(fixtures.TestBase): evt(target) m = MetaData() - t1 = Table('t1', m, + t1 = Table('t1', m, Column('id', Integer, Sequence('foo_id'), primary_key=True), Column('bar', String, ForeignKey('t2.id')), Column('bat', Integer, unique=True), @@ -1390,10 +1390,10 @@ class CatchAllEventsTest(fixtures.TestBase): eq_( canary, [ - 'PrimaryKeyConstraint->Table', 'PrimaryKeyConstraint->t1', + 'PrimaryKeyConstraint->Table', 'PrimaryKeyConstraint->t1', 'ForeignKeyConstraint->Table', 'ForeignKeyConstraint->t1', 'UniqueConstraint->Table', 'UniqueConstraint->t1', - 'PrimaryKeyConstraint->Table', 'PrimaryKeyConstraint->t2', + 'PrimaryKeyConstraint->Table', 'PrimaryKeyConstraint->t2', 'CheckConstraint->Table', 'CheckConstraint->t2', 'UniqueConstraint->Table', 'UniqueConstraint->t2' ] diff --git a/test/sql/test_query.py b/test/sql/test_query.py index 8a439c15c..0aefd4007 100644 --- a/test/sql/test_query.py +++ b/test/sql/test_query.py @@ -49,7 +49,7 @@ class QueryTest(fixtures.TestBase): def test_insert_heterogeneous_params(self): """test that executemany parameters are asserted to match the parameter set of the first.""" - assert_raises_message(exc.StatementError, + assert_raises_message(exc.StatementError, r"A value is required for bind parameter 'user_name', in " "parameter group 2 \(original cause: (sqlalchemy.exc.)?InvalidRequestError: A " "value is required for bind parameter 'user_name', in " @@ -60,7 +60,7 @@ class QueryTest(fixtures.TestBase): {'user_id':9} ) - # this succeeds however. We aren't yet doing + # this succeeds however. We aren't yet doing # a length check on all subsequent parameters. users.insert().execute( {'user_id':7}, @@ -99,7 +99,7 @@ class QueryTest(fixtures.TestBase): ret[col.key] = id if result.lastrow_has_defaults(): - criterion = and_(*[col==id for col, id in + criterion = and_(*[col==id for col, id in zip(table.primary_key, result.inserted_primary_key)]) row = engine.execute(table.select(criterion)).first() for c in table.c: @@ -217,7 +217,7 @@ class QueryTest(fixtures.TestBase): for engine in test_engines: - r = engine.execute(users.insert(), + r = engine.execute(users.insert(), {'user_name':'jack'}, ) assert r.closed @@ -312,7 +312,7 @@ class QueryTest(fixtures.TestBase): content = Table('content', self.metadata, Column('type', String(30)), ) - bar = Table('bar', self.metadata, + bar = Table('bar', self.metadata, Column('content_type', String(30)) ) self.metadata.create_all(testing.db) @@ -348,7 +348,7 @@ class QueryTest(fixtures.TestBase): result = util.pickle.loads(util.pickle.dumps(result)) eq_( - result, + result, [(7, "jack"), (8, "ed"), (9, "fred")] ) if use_labels: @@ -365,7 +365,7 @@ class QueryTest(fixtures.TestBase): if not pickle or use_labels: assert_raises(exc.NoSuchColumnError, lambda: result[0][addresses.c.user_id]) else: - # test with a different table. name resolution is + # test with a different table. name resolution is # causing 'user_id' to match when use_labels wasn't used. eq_(result[0][addresses.c.user_id], 7) @@ -387,7 +387,7 @@ class QueryTest(fixtures.TestBase): (unprintable(), "unprintable element.*"), ]: assert_raises_message( - exc.NoSuchColumnError, + exc.NoSuchColumnError, msg % repl, lambda: row[accessor] ) @@ -740,7 +740,7 @@ class QueryTest(fixtures.TestBase): dict(user_id=1, user_name='john'), ) - # test a little sqlite weirdness - with the UNION, + # test a little sqlite weirdness - with the UNION, # cols come back as "query_users.user_id" in cursor.description r = text("select query_users.user_id, query_users.user_name from query_users " "UNION select query_users.user_id, query_users.user_name from query_users", @@ -785,7 +785,7 @@ class QueryTest(fixtures.TestBase): ) # test using literal tablename.colname r = text('select query_users.user_id AS "query_users.user_id", ' - 'query_users.user_name AS "query_users.user_name" from query_users', + 'query_users.user_name AS "query_users.user_name" from query_users', bind=testing.db).execution_options(sqlite_raw_colnames=True).execute().first() eq_(r['query_users.user_id'], 1) eq_(r['query_users.user_name'], "john") @@ -1054,9 +1054,9 @@ class QueryTest(fixtures.TestBase): ) shadowed.create(checkfirst=True) try: - shadowed.insert().execute(shadow_id=1, shadow_name='The Shadow', parent='The Light', - row='Without light there is no shadow', - _parent='Hidden parent', + shadowed.insert().execute(shadow_id=1, shadow_name='The Shadow', parent='The Light', + row='Without light there is no shadow', + _parent='Hidden parent', _row='Hidden row') r = shadowed.select(shadowed.c.shadow_id==1).execute().first() self.assert_(r.shadow_id == r['shadow_id'] == r[shadowed.c.shadow_id] == 1) @@ -1104,7 +1104,7 @@ class QueryTest(fixtures.TestBase): @testing.fails_on('firebird', "uses sql-92 rules") @testing.fails_on('sybase', "uses sql-92 rules") @testing.fails_on('mssql+mxodbc', "uses sql-92 rules") - @testing.fails_if(lambda: + @testing.fails_if(lambda: testing.against('mssql+pyodbc') and not testing.db.dialect.freetds, "uses sql-92 rules") def test_bind_in(self): @@ -1144,7 +1144,7 @@ class QueryTest(fixtures.TestBase): @testing.emits_warning('.*empty sequence.*') @testing.requires.boolean_col_expressions def test_in_filtering_advanced(self): - """test the behavior of the in_() function when + """test the behavior of the in_() function when comparing against an empty collection, specifically that a proper boolean value is generated. @@ -1167,7 +1167,7 @@ class QueryTest(fixtures.TestBase): class PercentSchemaNamesTest(fixtures.TestBase): """tests using percent signs, spaces in table and column names. - Doesn't pass for mysql, postgresql, but this is really a + Doesn't pass for mysql, postgresql, but this is really a SQLAlchemy bug - we should be escaping out %% signs for this operation the same way we do for text() and column labels. @@ -1181,7 +1181,7 @@ class PercentSchemaNamesTest(fixtures.TestBase): Column("percent%", Integer), Column("spaces % more spaces", Integer), ) - lightweight_percent_table = sql.table('percent%table', + lightweight_percent_table = sql.table('percent%table', sql.column("percent%"), sql.column("spaces % more spaces"), ) @@ -1194,7 +1194,7 @@ class PercentSchemaNamesTest(fixtures.TestBase): def teardown_class(cls): metadata.drop_all() - @testing.skip_if(lambda: testing.against('postgresql'), + @testing.skip_if(lambda: testing.against('postgresql'), "psycopg2 2.4 no longer accepts % in bind placeholders") def test_single_roundtrip(self): percent_table.insert().execute( @@ -1211,7 +1211,7 @@ class PercentSchemaNamesTest(fixtures.TestBase): ) self._assert_table() - @testing.skip_if(lambda: testing.against('postgresql'), + @testing.skip_if(lambda: testing.against('postgresql'), "psycopg2 2.4 no longer accepts % in bind placeholders") @testing.crashes('mysql+mysqldb', "MySQLdb handles executemany() " "inconsistently vs. execute()") @@ -1228,9 +1228,9 @@ class PercentSchemaNamesTest(fixtures.TestBase): def _assert_table(self): for table in ( - percent_table, - percent_table.alias(), - lightweight_percent_table, + percent_table, + percent_table.alias(), + lightweight_percent_table, lightweight_percent_table.alias()): eq_( list( @@ -1314,7 +1314,7 @@ class KeyTargetingTest(fixtures.TablesTest): content = Table('content', metadata, Column('t', String(30), key="type"), ) - bar = Table('bar', metadata, + bar = Table('bar', metadata, Column('ctype', String(30), key="content_type") ) @@ -1611,7 +1611,7 @@ class CompoundTest(fixtures.TestBase): eq_(found2, wanted) def test_union_all_lightweight(self): - """like test_union_all, but breaks the sub-union into + """like test_union_all, but breaks the sub-union into a subquery with an explicit column reference on the outside, more palatable to a wider variety of engines. diff --git a/test/sql/test_quote.py b/test/sql/test_quote.py index 952b14763..a714002b1 100644 --- a/test/sql/test_quote.py +++ b/test/sql/test_quote.py @@ -94,7 +94,7 @@ class QuoteTest(fixtures.TestBase, AssertsCompiledSQL): self.assert_compile(t1.select().apply_labels(), '''SELECT "foo"."t1"."col1" AS "foo_t1_col1" FROM "foo"."t1"''') a = t1.select().alias('anon') b = select([1], a.c.col1==2, from_obj=a) - self.assert_compile(b, + self.assert_compile(b, '''SELECT 1 FROM (SELECT "foo"."t1"."col1" AS "col1" FROM '''\ '''"foo"."t1") AS anon WHERE anon."col1" = :col1_1''' ) @@ -104,15 +104,15 @@ class QuoteTest(fixtures.TestBase, AssertsCompiledSQL): Column('ColumnOne', Integer, quote=False), quote=False, schema="FooBar", quote_schema=False) self.assert_compile(t1.select(), "SELECT FooBar.TableOne.ColumnOne FROM FooBar.TableOne") - self.assert_compile(t1.select().apply_labels(), + self.assert_compile(t1.select().apply_labels(), "SELECT FooBar.TableOne.ColumnOne AS "\ - "FooBar_TableOne_ColumnOne FROM FooBar.TableOne" # TODO: is this what we really want here ? what if table/schema + "FooBar_TableOne_ColumnOne FROM FooBar.TableOne" # TODO: is this what we really want here ? what if table/schema # *are* quoted? ) a = t1.select().alias('anon') b = select([1], a.c.ColumnOne==2, from_obj=a) - self.assert_compile(b, + self.assert_compile(b, "SELECT 1 FROM (SELECT FooBar.TableOne.ColumnOne AS "\ "ColumnOne FROM FooBar.TableOne) AS anon WHERE anon.ColumnOne = :ColumnOne_1" ) @@ -142,8 +142,8 @@ class QuoteTest(fixtures.TestBase, AssertsCompiledSQL): if labels arent quoted, a query in postgresql in particular will fail since it produces: SELECT LaLa.lowercase, LaLa."UPPERCASE", LaLa."MixedCase", LaLa."ASC" - FROM (SELECT DISTINCT "WorstCase1".lowercase AS lowercase, - "WorstCase1"."UPPERCASE" AS UPPERCASE, + FROM (SELECT DISTINCT "WorstCase1".lowercase AS lowercase, + "WorstCase1"."UPPERCASE" AS UPPERCASE, "WorstCase1"."MixedCase" AS MixedCase, "WorstCase1"."ASC" AS ASC \nFROM "WorstCase1") AS LaLa where the "UPPERCASE" column of "LaLa" doesnt exist. @@ -179,7 +179,7 @@ class QuoteTest(fixtures.TestBase, AssertsCompiledSQL): Column("order", Integer)) x = select([table.c.col1, table.c['from'], table.c.louisville, table.c.order]) - self.assert_compile(x, + self.assert_compile(x, '''SELECT "ImATable".col1, "ImATable"."from", "ImATable".louisville, "ImATable"."order" FROM "ImATable"''') diff --git a/test/sql/test_rowcount.py b/test/sql/test_rowcount.py index 5d95baa81..c14fa22a1 100644 --- a/test/sql/test_rowcount.py +++ b/test/sql/test_rowcount.py @@ -13,8 +13,8 @@ class FoundRowsTest(fixtures.TestBase, AssertsExecutionResults): metadata = MetaData(testing.db) employees_table = Table('employees', metadata, - Column('employee_id', Integer, - Sequence('employee_id_seq', optional=True), + Column('employee_id', Integer, + Sequence('employee_id_seq', optional=True), primary_key=True), Column('name', String(50)), Column('department', String(1)), diff --git a/test/sql/test_types.py b/test/sql/test_types.py index 659c7f2ae..91bf17175 100644 --- a/test/sql/test_types.py +++ b/test/sql/test_types.py @@ -26,7 +26,7 @@ class AdaptTest(fixtures.TestBase): ] def _all_dialects(self): - return [d.base.dialect() for d in + return [d.base.dialect() for d in self._all_dialect_modules()] def _types_for_mod(self, mod): @@ -327,11 +327,11 @@ class UserDefinedTest(fixtures.TablesTest, AssertsCompiledSQL): self.assert_compile(t, "VARCHAR(50)", dialect=sl) self.assert_compile(t, "FLOAT", dialect=pg) eq_( - t.dialect_impl(dialect=sl).impl.__class__, + t.dialect_impl(dialect=sl).impl.__class__, String().dialect_impl(dialect=sl).__class__ ) eq_( - t.dialect_impl(dialect=pg).impl.__class__, + t.dialect_impl(dialect=pg).impl.__class__, Float().dialect_impl(pg).__class__ ) @@ -695,8 +695,8 @@ class UnicodeTest(fixtures.TestBase, AssertsExecutionResults): ('oracle','cx_oracle'), )), \ "name: %s driver %s returns_unicode_strings=%s" % \ - (testing.db.name, - testing.db.driver, + (testing.db.name, + testing.db.driver, testing.db.dialect.returns_unicode_strings) def test_round_trip(self): @@ -787,7 +787,7 @@ class UnicodeTest(fixtures.TestBase, AssertsExecutionResults): eq_(uni(unicodedata), unicodedata.encode('utf-8')) - # using convert unicode at engine level - + # using convert unicode at engine level - # this should not be raising a warning unicode_engine = engines.utf8_engine(options={'convert_unicode':True,}) unicode_engine.dialect.supports_unicode_binds = False @@ -836,7 +836,7 @@ class UnicodeTest(fixtures.TestBase, AssertsExecutionResults): engine = engines.testing_engine(options={'encoding':'ascii'}) m.create_all(engine) try: - # insert a row that should be ascii and + # insert a row that should be ascii and # coerce from unicode with ignore on the bind side engine.execute( table.insert(), @@ -871,7 +871,7 @@ class UnicodeTest(fixtures.TestBase, AssertsExecutionResults): # one row will be ascii with ignores, # the other will be either ascii with the ignores - # or just the straight unicode+ utf8 value if the + # or just the straight unicode+ utf8 value if the # dialect just returns unicode result = engine.execute(table.select().order_by(table.c.sort)) ascii_row = result.fetchone() @@ -929,10 +929,10 @@ class EnumTest(fixtures.TestBase): def teardown_class(cls): metadata.drop_all() - @testing.fails_on('postgresql+zxjdbc', + @testing.fails_on('postgresql+zxjdbc', 'zxjdbc fails on ENUM: column "XXX" is of type XXX ' 'but expression is of type character varying') - @testing.fails_on('postgresql+pg8000', + @testing.fails_on('postgresql+pg8000', 'zxjdbc fails on ENUM: column "XXX" is of type XXX ' 'but expression is of type text') def test_round_trip(self): @@ -943,7 +943,7 @@ class EnumTest(fixtures.TestBase): ]) eq_( - enum_table.select().order_by(enum_table.c.id).execute().fetchall(), + enum_table.select().order_by(enum_table.c.id).execute().fetchall(), [ (1, 'two'), (2, 'two'), @@ -960,7 +960,7 @@ class EnumTest(fixtures.TestBase): eq_( non_native_enum_table.select(). - order_by(non_native_enum_table.c.id).execute().fetchall(), + order_by(non_native_enum_table.c.id).execute().fetchall(), [ (1, 'two'), (2, 'two'), @@ -978,19 +978,19 @@ class EnumTest(fixtures.TestBase): eq_(e1.adapt(ENUM).name, 'foo') eq_(e1.adapt(ENUM).schema, 'bar') - @testing.crashes('mysql', + @testing.crashes('mysql', 'Inconsistent behavior across various OS/drivers' ) def test_constraint(self): - assert_raises(exc.DBAPIError, + assert_raises(exc.DBAPIError, enum_table.insert().execute, {'id':4, 'someenum':'four'} ) - @testing.fails_on('mysql', + @testing.fails_on('mysql', "the CHECK constraint doesn't raise an exception for unknown reason") def test_non_native_constraint(self): - assert_raises(exc.DBAPIError, + assert_raises(exc.DBAPIError, non_native_enum_table.insert().execute, {'id':4, 'someenum':'four'} ) @@ -1004,7 +1004,7 @@ class EnumTest(fixtures.TestBase): Column('x', Enum("x", "y", name="pge")) ) t.create(e, checkfirst=False) - # basically looking for the start of + # basically looking for the start of # the constraint, or the ENUM def itself, # depending on backend. assert "('x'," in e.print_sql() @@ -1058,32 +1058,32 @@ class BinaryTest(fixtures.TestBase, AssertsExecutionResults): stream1 =self.load_stream('binary_data_one.dat') stream2 =self.load_stream('binary_data_two.dat') binary_table.insert().execute( - primary_id=1, - misc='binary_data_one.dat', - data=stream1, - data_slice=stream1[0:100], - pickled=testobj1, + primary_id=1, + misc='binary_data_one.dat', + data=stream1, + data_slice=stream1[0:100], + pickled=testobj1, mypickle=testobj3) binary_table.insert().execute( - primary_id=2, - misc='binary_data_two.dat', - data=stream2, - data_slice=stream2[0:99], + primary_id=2, + misc='binary_data_two.dat', + data=stream2, + data_slice=stream2[0:99], pickled=testobj2) binary_table.insert().execute( - primary_id=3, - misc='binary_data_two.dat', - data=None, - data_slice=stream2[0:99], + primary_id=3, + misc='binary_data_two.dat', + data=None, + data_slice=stream2[0:99], pickled=None) for stmt in ( binary_table.select(order_by=binary_table.c.primary_id), text( - "select * from binary_table order by binary_table.primary_id", - typemap={'pickled':PickleType, - 'mypickle':MyPickleType, - 'data':LargeBinary, 'data_slice':LargeBinary}, + "select * from binary_table order by binary_table.primary_id", + typemap={'pickled':PickleType, + 'mypickle':MyPickleType, + 'data':LargeBinary, 'data_slice':LargeBinary}, bind=testing.db) ): l = stmt.execute().fetchall() @@ -1154,9 +1154,9 @@ class ExpressionTest(fixtures.TestBase, AssertsExecutionResults, AssertsCompiled meta.create_all() test_table.insert().execute({ - 'id':1, - 'data':'somedata', - 'atimestamp':datetime.date(2007, 10, 15), + 'id':1, + 'data':'somedata', + 'atimestamp':datetime.date(2007, 10, 15), 'avalue':25, 'bvalue':'foo'}) @classmethod @@ -1180,7 +1180,7 @@ class ExpressionTest(fixtures.TestBase, AssertsExecutionResults, AssertsCompiled eq_( testing.db.execute( select([test_table.c.id, test_table.c.data, test_table.c.atimestamp]) - .where(expr), + .where(expr), {"thedate":datetime.date(2007, 10, 15)}).fetchall(), [(1, 'somedata', datetime.date(2007, 10, 15))] ) @@ -1199,9 +1199,9 @@ class ExpressionTest(fixtures.TestBase, AssertsExecutionResults, AssertsCompiled eq_(expr.right.type._type_affinity, String) eq_( - testing.db.execute(test_table.select().where(expr), + testing.db.execute(test_table.select().where(expr), {"somevalue":"foo"}).fetchall(), - [(1, 'somedata', + [(1, 'somedata', datetime.date(2007, 10, 15), 25, 'BIND_INfooBIND_OUT')] ) @@ -1358,7 +1358,7 @@ class ExpressionTest(fixtures.TestBase, AssertsExecutionResults, AssertsCompiled def test_null_comparison(self): eq_( - str(column('a', types.NullType()) + column('b', types.NullType())), + str(column('a', types.NullType()) + column('b', types.NullType())), "a + b" ) @@ -1577,7 +1577,7 @@ class NumericTest(fixtures.TestBase): self._do_test( Numeric(precision=8, scale=4), [15.7563, decimal.Decimal("15.7563"), None], - [decimal.Decimal("15.7563"), None], + [decimal.Decimal("15.7563"), None], ) def test_numeric_as_float(self): @@ -1597,7 +1597,7 @@ class NumericTest(fixtures.TestBase): self._do_test( Float(precision=8, asdecimal=True), [15.7563, decimal.Decimal("15.7563"), None], - [decimal.Decimal("15.7563"), None], + [decimal.Decimal("15.7563"), None], filter_ = lambda n:n is not None and round(n, 5) or None ) @@ -1613,8 +1613,8 @@ class NumericTest(fixtures.TestBase): def test_precision_decimal(self): numbers = set([ decimal.Decimal("54.234246451650"), - decimal.Decimal("0.004354"), - decimal.Decimal("900.0"), + decimal.Decimal("0.004354"), + decimal.Decimal("900.0"), ]) self._do_test( @@ -1627,7 +1627,7 @@ class NumericTest(fixtures.TestBase): def test_enotation_decimal(self): """test exceedingly small decimals. - Decimal reports values with E notation when the exponent + Decimal reports values with E notation when the exponent is greater than 6. """ @@ -1652,7 +1652,7 @@ class NumericTest(fixtures.TestBase): numbers ) - @testing.fails_on("sybase+pyodbc", + @testing.fails_on("sybase+pyodbc", "Don't know how do get these values through FreeTDS + Sybase") @testing.fails_on("firebird", "Precision must be from 1 to 18") def test_enotation_decimal_large(self): @@ -1692,7 +1692,7 @@ class NumericTest(fixtures.TestBase): "this may be a bug due to the difficulty in handling " "oracle precision numerics" ) - @testing.fails_on('postgresql+pg8000', + @testing.fails_on('postgresql+pg8000', "pg-8000 does native decimal but truncates the decimals.") def test_numeric_no_decimal(self): numbers = set([ @@ -1794,8 +1794,8 @@ class IntervalTest(fixtures.TestBase, AssertsExecutionResults): small_delta = datetime.timedelta(days=15, seconds=5874) delta = datetime.timedelta(414) interval_table.insert().execute( - native_interval=small_delta, - native_interval_args=delta, + native_interval=small_delta, + native_interval_args=delta, non_native_interval=delta ) row = interval_table.select().execute().first() @@ -1851,22 +1851,22 @@ class BooleanTest(fixtures.TestBase, AssertsExecutionResults): res3 = select([bool_table.c.id, bool_table.c.value]).\ order_by(bool_table.c.id).\ execute().fetchall() - eq_(res3, [(1, True), (2, False), - (3, True), (4, True), + eq_(res3, [(1, True), (2, False), + (3, True), (4, True), (5, True), (6, None)]) # ensure we're getting True/False, not just ints assert res3[0][1] is True assert res3[1][1] is False - @testing.fails_on('mysql', + @testing.fails_on('mysql', "The CHECK clause is parsed but ignored by all storage engines.") - @testing.fails_on('mssql', + @testing.fails_on('mssql', "FIXME: MS-SQL 2005 doesn't honor CHECK ?!?") @testing.skip_if(lambda: testing.db.dialect.supports_native_boolean) def test_constraint(self): assert_raises((exc.IntegrityError, exc.ProgrammingError), - testing.db.execute, + testing.db.execute, "insert into booltest (id, value) values(1, 5)") @testing.skip_if(lambda: testing.db.dialect.supports_native_boolean) @@ -1885,7 +1885,7 @@ class PickleTest(fixtures.TestBase): ): assert p1.compare_values(p1.copy_value(obj), obj) - assert_raises(NotImplementedError, + assert_raises(NotImplementedError, p1.compare_values, pickleable.BrokenComparable('foo'), pickleable.BrokenComparable('foo')) diff --git a/test/sql/test_unicode.py b/test/sql/test_unicode.py index 19f672f77..e3fa0a4b3 100644 --- a/test/sql/test_unicode.py +++ b/test/sql/test_unicode.py @@ -130,7 +130,7 @@ class EscapesDefaultsTest(fixtures.TestBase): select([column(u'special_col')]).select_from(t1).execute().close() assert isinstance(engine.dialect.identifier_preparer.format_sequence(Sequence('special_col')), unicode) - # now execute, run the sequence. it should run in u"Special_col.nextid" or similar as + # now execute, run the sequence. it should run in u"Special_col.nextid" or similar as # a unicode object; cx_oracle asserts that this is None or a String (postgresql lets it pass thru). # ensure that executioncontext._exec_default() is encoding. t1.insert().execute(data='foo') diff --git a/test/sql/test_update.py b/test/sql/test_update.py index f900a164c..79079e512 100644 --- a/test/sql/test_update.py +++ b/test/sql/test_update.py @@ -11,13 +11,13 @@ class _UpdateFromTestBase(object): @classmethod def define_tables(cls, metadata): Table('users', metadata, - Column('id', Integer, primary_key=True, + Column('id', Integer, primary_key=True, test_needs_autoincrement=True), Column('name', String(30), nullable=False), ) Table('addresses', metadata, - Column('id', Integer, primary_key=True, + Column('id', Integer, primary_key=True, test_needs_autoincrement=True), Column('user_id', None, ForeignKey('users.id')), Column('name', String(30), nullable=False), @@ -25,7 +25,7 @@ class _UpdateFromTestBase(object): ) Table("dingalings", metadata, - Column('id', Integer, primary_key=True, + Column('id', Integer, primary_key=True, test_needs_autoincrement=True), Column('address_id', None, ForeignKey('addresses.id')), Column('data', String(30)), @@ -93,7 +93,7 @@ class UpdateFromCompileTest(_UpdateFromTestBase, fixtures.TablesTest, AssertsCom "AND addresses.email_address = :email_address_1 " "AND addresses.id = dingalings.address_id AND " "dingalings.id = :id_1", - checkparams={u'email_address_1': 'e1', u'id_1': 2, + checkparams={u'email_address_1': 'e1', u'id_1': 2, 'name': 'newname'} ) @@ -113,8 +113,8 @@ class UpdateFromCompileTest(_UpdateFromTestBase, fixtures.TablesTest, AssertsCom def test_render_subquery(self): users, addresses = self.tables.users, self.tables.addresses - subq = select([addresses.c.id, - addresses.c.user_id, + subq = select([addresses.c.id, + addresses.c.user_id, addresses.c.email_address]).\ where(addresses.c.id==7).alias() self.assert_compile( @@ -128,7 +128,7 @@ class UpdateFromCompileTest(_UpdateFromTestBase, fixtures.TablesTest, AssertsCom "email_address FROM addresses WHERE addresses.id = " ":id_1) AS anon_1 WHERE users.id = anon_1.user_id " "AND anon_1.email_address = :email_address_1", - checkparams={u'email_address_1': 'e1', + checkparams={u'email_address_1': 'e1', u'id_1': 7, 'name': 'newname'} ) @@ -214,7 +214,7 @@ class UpdateFromRoundTripTest(_UpdateFromTestBase, fixtures.TablesTest): testing.db.execute( addresses.update().\ values({ - addresses.c.email_address:users.c.name, + addresses.c.email_address:users.c.name, users.c.name:'ed2' }).\ where(users.c.id==addresses.c.user_id).\ @@ -246,14 +246,14 @@ class UpdateFromMultiTableUpdateDefaultsTest(_UpdateFromTestBase, fixtures.Table @classmethod def define_tables(cls, metadata): Table('users', metadata, - Column('id', Integer, primary_key=True, + Column('id', Integer, primary_key=True, test_needs_autoincrement=True), Column('name', String(30), nullable=False), Column('some_update', String(30), onupdate="im the update") ) Table('addresses', metadata, - Column('id', Integer, primary_key=True, + Column('id', Integer, primary_key=True, test_needs_autoincrement=True), Column('user_id', None, ForeignKey('users.id')), Column('email_address', String(50), nullable=False), @@ -282,7 +282,7 @@ class UpdateFromMultiTableUpdateDefaultsTest(_UpdateFromTestBase, fixtures.Table ret = testing.db.execute( addresses.update().\ values({ - addresses.c.email_address:users.c.name, + addresses.c.email_address:users.c.name, users.c.name:'ed2' }).\ where(users.c.id==addresses.c.user_id).\ @@ -316,7 +316,7 @@ class UpdateFromMultiTableUpdateDefaultsTest(_UpdateFromTestBase, fixtures.Table ret = testing.db.execute( addresses.update().\ values({ - 'email_address':users.c.name, + 'email_address':users.c.name, }).\ where(users.c.id==addresses.c.user_id).\ where(users.c.name=='ed') @@ -333,7 +333,7 @@ class UpdateFromMultiTableUpdateDefaultsTest(_UpdateFromTestBase, fixtures.Table (4, 9, "fred@fred.com") ] ) - # users table not actually updated, + # users table not actually updated, # so no onupdate eq_( testing.db.execute( |
