]> git.ipfire.org Git - thirdparty/sqlalchemy/sqlalchemy.git/commitdiff
make it more explicit in tests which dialect we want to use for things
authorMike Bayer <mike_mp@zzzcomputing.com>
Fri, 11 Feb 2011 16:24:54 +0000 (11:24 -0500)
committerMike Bayer <mike_mp@zzzcomputing.com>
Fri, 11 Feb 2011 16:24:54 +0000 (11:24 -0500)
12 files changed:
test/dialect/test_postgresql.py
test/engine/test_reflection.py
test/ext/test_compiler.py
test/ext/test_hybrid.py
test/lib/testing.py
test/sql/test_case_statement.py
test/sql/test_compiler.py
test/sql/test_constraints.py
test/sql/test_functions.py
test/sql/test_generative.py
test/sql/test_quote.py
test/sql/test_types.py

index 424e8b5d9c462e5153899dd679b2b8ed1f69128f..5d67e19216a8e2eb9cd37d1f5deeb36e2d1f45aa 100644 (file)
@@ -2094,16 +2094,14 @@ class MatchTest(TestBase, AssertsCompiledSQL):
     def test_expression_pyformat(self):
         self.assert_compile(matchtable.c.title.match('somstr'),
                             'matchtable.title @@ to_tsquery(%(title_1)s'
-                            ')',
-                            dialect=postgresql.dialect())
+                            ')')
 
     @testing.fails_on('postgresql+psycopg2', 'uses pyformat')
     @testing.fails_on('postgresql+pypostgresql', 'uses pyformat')
     @testing.fails_on('postgresql+zxjdbc', 'uses qmark')
     def test_expression_positional(self):
         self.assert_compile(matchtable.c.title.match('somstr'),
-                            'matchtable.title @@ to_tsquery(%s)',
-                            dialect=postgresql.dialect())
+                            'matchtable.title @@ to_tsquery(%s)')
 
     def test_simple_match(self):
         results = \
index e23633802bd5e2a63b171be206323ebd7d21cd7d..a83c332cb0bc68526e9db894e1ebdf5b12e3912d 100644 (file)
@@ -1133,6 +1133,7 @@ def _drop_views(con, schema=None):
 
 
 class ReverseCasingReflectTest(TestBase, AssertsCompiledSQL):
+    __dialect__ = 'default'
 
     @testing.requires.denormalized_names
     def setup(self):
index 116b0f229314881de851d29f73da3752d28c4cfc..eaa46cc28d74f1c275d622fb6156c2188e511c49 100644 (file)
@@ -10,6 +10,7 @@ from sqlalchemy.sql import table, column, visitors
 from test.lib import *
 
 class UserDefinedTest(TestBase, AssertsCompiledSQL):
+    __dialect__ = 'default'
 
     def test_column(self):
 
@@ -266,6 +267,7 @@ class UserDefinedTest(TestBase, AssertsCompiledSQL):
 
 class DefaultOnExistingTest(TestBase, AssertsCompiledSQL):
     """Test replacement of default compilation on existing constructs."""
+    __dialect__ = 'default'
 
     def teardown(self):
         for cls in (Select, _BindParamClause):
index 201d3821f640aebf6bc96499cd514181e19f2de2..cab1c90bb374d1cfc681b0845e1d00d22423034e 100644 (file)
@@ -6,6 +6,7 @@ from sqlalchemy.ext import hybrid
 from test.lib.testing import TestBase, eq_, AssertsCompiledSQL
 
 class PropertyComparatorTest(TestBase, AssertsCompiledSQL):
+    __dialect__ = 'default'
 
     def _fixture(self):
         Base = declarative_base()
@@ -77,6 +78,7 @@ class PropertyComparatorTest(TestBase, AssertsCompiledSQL):
         )
 
 class PropertyExpressionTest(TestBase, AssertsCompiledSQL):
+    __dialect__ = 'default'
     def _fixture(self):
         Base = declarative_base()
 
@@ -142,6 +144,7 @@ class PropertyExpressionTest(TestBase, AssertsCompiledSQL):
         )
 
 class PropertyValueTest(TestBase, AssertsCompiledSQL):
+    __dialect__ = 'default'
     def _fixture(self):
         Base = declarative_base()
 
@@ -167,6 +170,7 @@ class PropertyValueTest(TestBase, AssertsCompiledSQL):
         eq_(a1._value, 10)
 
 class MethodExpressionTest(TestBase, AssertsCompiledSQL):
+    __dialect__ = 'default'
     def _fixture(self):
         Base = declarative_base()
 
index 36a8c8d1a4786832141f079f44ed7c6f4a150c07..bf852de7cd6ef8ce3c5288fdfebb2fdb8fc090e1 100644 (file)
@@ -628,12 +628,17 @@ class TestBase(object):
 class AssertsCompiledSQL(object):
     def assert_compile(self, clause, result, params=None, 
                         checkparams=None, dialect=None, 
-                        use_default_dialect=False):
+                        use_default_dialect=False,
+                        allow_dialect_select=False):
+
         if use_default_dialect:
             dialect = default.DefaultDialect()
-
-        if dialect is None:
+        elif dialect == None and not allow_dialect_select:
             dialect = getattr(self, '__dialect__', None)
+            if dialect == 'default':
+                dialect = default.DefaultDialect()
+            elif dialect is None:
+                dialect = db.dialect
 
         kw = {}
         if params is not None:
index 97220d4dd9afa5dc2916f56687653163579303ee..4bb9cf0fc069d2960c6bac3cd58820353ff36084 100644 (file)
@@ -7,6 +7,7 @@ from sqlalchemy.sql import table, column
 
 
 class CaseTest(TestBase, AssertsCompiledSQL):
+    __dialect__ = 'default'
 
     @classmethod
     def setup_class(cls):
index 4ede5632048a966d70f0de5ad4273b3c4cc3537a..b060fef5b00ca0303d1c55a4a9cae04e23637198 100644 (file)
@@ -62,6 +62,7 @@ addresses = table('addresses',
 )
 
 class SelectTest(TestBase, AssertsCompiledSQL):
+    __dialect__ = 'default'
 
     def test_attribute_sanity(self):
         assert hasattr(table1, 'c')
@@ -2417,6 +2418,8 @@ class SelectTest(TestBase, AssertsCompiledSQL):
 
 
 class CRUDTest(TestBase, AssertsCompiledSQL):
+    __dialect__ = 'default'
+
     def test_insert(self):
         # generic insert, will create bind params for all columns
         self.assert_compile(insert(table1), 
@@ -2671,6 +2674,8 @@ class CRUDTest(TestBase, AssertsCompiledSQL):
         )
 
 class InlineDefaultTest(TestBase, AssertsCompiledSQL):
+    __dialect__ = 'default'
+
     def test_insert(self):
         m = MetaData()
         foo =  Table('foo', m,
@@ -2703,6 +2708,8 @@ class InlineDefaultTest(TestBase, AssertsCompiledSQL):
                         "col3=:col3")
 
 class SchemaTest(TestBase, AssertsCompiledSQL):
+    __dialect__ = 'default'
+
     def test_select(self):
         self.assert_compile(table4.select(), 
                 "SELECT remote_owner.remotetable.rem_id, remote_owner.remotetable.datatype_id,"
index f4791c0bdeeb21fb9887a0764a9f1cbf50bb7282..1c13a0ec7adc992f389ace7e4372c81d4e8fae94 100644 (file)
@@ -256,6 +256,7 @@ class ConstraintTest(TestBase, AssertsExecutionResults, AssertsCompiledSQL):
         )
 
 class ConstraintCompilationTest(TestBase, AssertsCompiledSQL):
+    __dialect__ = 'default'
 
     def _test_deferrable(self, constraint_factory):
         t = Table('tbl', MetaData(),
index b0106b21baef8a90d7dcdc0193bb3fa686154ae8..98d8d7a970bee8399eba3fd565144fc852bf3bf4 100644 (file)
@@ -16,6 +16,7 @@ from sqlalchemy.databases import *
 
 
 class CompileTest(TestBase, AssertsCompiledSQL):
+    __dialect__ = 'default'
 
     def test_compile(self):
         for dialect in all_dialects(exclude=('sybase', 'access', 'informix', 'maxdb')):
index c6f5dc05ef9450c2e9f786626c3f448bdf66e1c9..088162c8a6ca65bdd3109b6d204ad27c950091b0 100644 (file)
@@ -169,6 +169,8 @@ class TraversalTest(TestBase, AssertsExecutionResults):
 class ClauseTest(TestBase, AssertsCompiledSQL):
     """test copy-in-place behavior of various ClauseElements."""
 
+    __dialect__ = 'default'
+
     @classmethod
     def setup_class(cls):
         global t1, t2
@@ -471,6 +473,8 @@ class ClauseTest(TestBase, AssertsCompiledSQL):
                             'anon_1.col1')
 
 class ClauseAdapterTest(TestBase, AssertsCompiledSQL):
+    __dialect__ = 'default'
+
     @classmethod
     def setup_class(cls):
         global t1, t2
@@ -858,6 +862,8 @@ class ClauseAdapterTest(TestBase, AssertsCompiledSQL):
         )
 
 class SpliceJoinsTest(TestBase, AssertsCompiledSQL):
+    __dialect__ = 'default'
+
     @classmethod
     def setup_class(cls):
         global table1, table2, table3, table4
@@ -929,6 +935,8 @@ class SpliceJoinsTest(TestBase, AssertsCompiledSQL):
 class SelectTest(TestBase, AssertsCompiledSQL):
     """tests the generative capability of Select"""
 
+    __dialect__ = 'default'
+
     @classmethod
     def setup_class(cls):
         global t1, t2
@@ -1083,6 +1091,8 @@ class SelectTest(TestBase, AssertsCompiledSQL):
 class InsertTest(TestBase, AssertsCompiledSQL):
     """Tests the generative capability of Insert"""
 
+    __dialect__ = 'default'
+
     # fixme: consolidate converage from elsewhere here and expand
 
     @classmethod
index 2aa5086c6200db6fb5e147993e496bb6b8152689..50adad7512c7817ada75ee32dbfe69b8401676d8 100644 (file)
@@ -4,6 +4,8 @@ from sqlalchemy.sql import compiler
 from test.lib import *
 
 class QuoteTest(TestBase, AssertsCompiledSQL):
+    __dialect__ = 'default'
+
     @classmethod
     def setup_class(cls):
         # TODO: figure out which databases/which identifiers allow special
index 52db03d76912efebef167ade45434b59316fd8d3..226283195274e8529f23e3b435101121f110b073 100644 (file)
@@ -873,6 +873,8 @@ class BinaryTest(TestBase, AssertsExecutionResults):
         return open(f, mode='rb').read()
 
 class ExpressionTest(TestBase, AssertsExecutionResults, AssertsCompiledSQL):
+    __dialect__ = 'default'
+
     @classmethod
     def setup_class(cls):
         global test_table, meta, MyCustomType, MyTypeDec
@@ -1153,7 +1155,8 @@ class CompileTest(TestBase, AssertsCompiledSQL):
             (INTEGER(), "INTEGER"),
             (dialects.mysql.INTEGER(display_width=5), "INTEGER(5)")
         ):
-            self.assert_compile(type_, expected)
+            self.assert_compile(type_, expected,
+                                allow_dialect_select=True)
 
 class DateTest(TestBase, AssertsExecutionResults):
     @classmethod