From: Mike Bayer Date: Sun, 24 Jul 2016 20:36:27 +0000 (-0400) Subject: - a variety of test adjustments to accomodate for MySQL 5.7 X-Git-Tag: rel_1_1_0b3~5 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=02190234a25bb5ed2b07d25e6adcece2f5bba763;p=thirdparty%2Fsqlalchemy%2Fsqlalchemy.git - a variety of test adjustments to accomodate for MySQL 5.7 Change-Id: Ied4245433d0d7b469dae6e7394c4931d8405f387 --- diff --git a/test/dialect/mysql/test_reflection.py b/test/dialect/mysql/test_reflection.py index 44880c36b9..ddf1581678 100644 --- a/test/dialect/mysql/test_reflection.py +++ b/test/dialect/mysql/test_reflection.py @@ -98,7 +98,6 @@ class TypeReflectionTest(fixtures.TestBase): def test_year_types(self): specs = [ (mysql.YEAR(), mysql.YEAR(display_width=4)), - (mysql.YEAR(display_width=2), mysql.YEAR(display_width=2)), (mysql.YEAR(display_width=4), mysql.YEAR(display_width=4)), ] diff --git a/test/dialect/mysql/test_types.py b/test/dialect/mysql/test_types.py index 7b7cf36679..0cbb507c54 100644 --- a/test/dialect/mysql/test_types.py +++ b/test/dialect/mysql/test_types.py @@ -485,6 +485,7 @@ class TypesTest(fixtures.TestBase, AssertsExecutionResults, AssertsCompiledSQL): ) + @testing.requires.mysql_zero_date @testing.provide_metadata def test_timestamp_nullable(self): ts_table = Table( @@ -779,7 +780,7 @@ class EnumSetTest( exc.StatementError, set_table.insert().execute, e1='c', e2='c', e3='c', e4='c') - @testing.fails_on("+oursql", "oursql raises on the truncate warning") + @testing.requires.mysql_non_strict @testing.provide_metadata def test_empty_set_no_empty_string(self): t = Table( diff --git a/test/engine/test_transaction.py b/test/engine/test_transaction.py index 7eda6e1b4d..4d8d1795a5 100644 --- a/test/engine/test_transaction.py +++ b/test/engine/test_transaction.py @@ -433,12 +433,7 @@ class TransactionTest(fixtures.TestBase): connection.close() @testing.requires.two_phase_transactions - @testing.crashes('mysql+oursql', - 'Times out in full test runs only, causing ' - 'subsequent tests to fail') - @testing.crashes('mysql+zxjdbc', - 'Deadlocks, causing subsequent tests to fail') - @testing.fails_on('mysql', 'FIXME: unknown') + @testing.requires.two_phase_recovery def test_two_phase_recover(self): # MySQL recovery doesn't currently seem to work correctly diff --git a/test/ext/test_indexable.py b/test/ext/test_indexable.py index b9e942e4b2..3df49cf86a 100644 --- a/test/ext/test_indexable.py +++ b/test/ext/test_indexable.py @@ -243,7 +243,10 @@ class IndexPropertyArrayTest(fixtures.DeclarativeMappedTest): class IndexPropertyJsonTest(fixtures.DeclarativeMappedTest): + # TODO: remove reliance on "astext" for these tests __requires__ = ('json_type',) + __only_on__ = 'postgresql' + __backend__ = True @classmethod diff --git a/test/orm/inheritance/test_abc_inheritance.py b/test/orm/inheritance/test_abc_inheritance.py index 757f8868ed..3fc5d52bc3 100644 --- a/test/orm/inheritance/test_abc_inheritance.py +++ b/test/orm/inheritance/test_abc_inheritance.py @@ -114,6 +114,7 @@ def produce_test(parent, child, direction): relationship(child_mapper, primaryjoin=relationshipjoin, foreign_keys=foreign_keys, + order_by=child_mapper.c.id, remote_side=remote_side, uselist=True)) sess = create_session() @@ -177,4 +178,4 @@ for parent in ["a", "b", "c"]: exec("%s = testclass" % testclass.__name__) del testclass -del produce_test \ No newline at end of file +del produce_test diff --git a/test/orm/inheritance/test_polymorphic_rel.py b/test/orm/inheritance/test_polymorphic_rel.py index 5e810bb3cb..32369c8a42 100644 --- a/test/orm/inheritance/test_polymorphic_rel.py +++ b/test/orm/inheritance/test_polymorphic_rel.py @@ -569,7 +569,8 @@ class _PolymorphicTestBase(object): sess = create_session() def go(): eq_(sess.query(Person) - .with_polymorphic(Engineer).all(), + .with_polymorphic(Engineer). + order_by(Person.person_id).all(), self._emps_wo_relationships_fixture()) self.assert_sql_count(testing.db, go, 3) @@ -580,6 +581,7 @@ class _PolymorphicTestBase(object): .with_polymorphic( Engineer, people.outerjoin(engineers)) + .order_by(Person.person_id) .all(), self._emps_wo_relationships_fixture()) self.assert_sql_count(testing.db, go, 3) diff --git a/test/requirements.py b/test/requirements.py index 3c7a3fbb41..c906cf5249 100644 --- a/test/requirements.py +++ b/test/requirements.py @@ -440,6 +440,18 @@ class DefaultRequirements(SuiteRequirements): 'two-phase xact not supported by database'), ]) + @property + def two_phase_recovery(self): + return self.two_phase_transactions + ( + exclusions.fails_if( + lambda config: config.db.name == 'mysql' and ( + 'MariaDB' in config.db.dialect.server_version_info or + config.db.dialect.server_version_info < (5, 7) + ) + ) + ) + + @property def views(self): """Target database must support VIEWs.""" @@ -914,6 +926,22 @@ class DefaultRequirements(SuiteRequirements): def mysql_fully_case_sensitive(self): return only_if(self._has_mysql_fully_case_sensitive) + @property + def mysql_zero_date(self): + def check(config): + row = config.db.execute("show variables like 'sql_mode'").first() + return not row or "NO_ZERO_DATE" not in row[1] + + return only_if(check) + + @property + def mysql_non_strict(self): + def check(config): + row = config.db.execute("show variables like 'sql_mode'").first() + return not row or "STRICT" not in row[1] + + return only_if(check) + def _has_mysql_on_windows(self, config): return against(config, 'mysql') and \ config.db.dialect._detect_casing(config.db) == 1 diff --git a/test/sql/test_update.py b/test/sql/test_update.py index 8726710083..556bb848e1 100644 --- a/test/sql/test_update.py +++ b/test/sql/test_update.py @@ -643,7 +643,7 @@ class UpdateFromRoundTripTest(_UpdateFromTestBase, fixtures.TablesTest): users, addresses = self.tables.users, self.tables.addresses values = { - addresses.c.email_address: users.c.name, + addresses.c.email_address: 'updated', users.c.name: 'ed2' } @@ -655,9 +655,9 @@ class UpdateFromRoundTripTest(_UpdateFromTestBase, fixtures.TablesTest): expected = [ (1, 7, 'x', 'jack@bean.com'), - (2, 8, 'x', 'ed'), - (3, 8, 'x', 'ed'), - (4, 8, 'x', 'ed'), + (2, 8, 'x', 'updated'), + (3, 8, 'x', 'updated'), + (4, 8, 'x', 'updated'), (5, 9, 'x', 'fred@fred.com')] self._assert_addresses(addresses, expected) @@ -761,7 +761,7 @@ class UpdateFromMultiTableUpdateDefaultsTest(_UpdateFromTestBase, users, addresses = self.tables.users, self.tables.addresses values = { - addresses.c.email_address: users.c.name, + addresses.c.email_address: 'updated', users.c.name: 'ed2' } @@ -774,8 +774,8 @@ class UpdateFromMultiTableUpdateDefaultsTest(_UpdateFromTestBase, eq_(set(ret.prefetch_cols()), set([users.c.some_update])) expected = [ - (2, 8, 'ed'), - (3, 8, 'ed'), + (2, 8, 'updated'), + (3, 8, 'updated'), (4, 9, 'fred@fred.com')] self._assert_addresses(addresses, expected)