From: Mike Bayer Date: Fri, 11 Feb 2011 16:24:54 +0000 (-0500) Subject: make it more explicit in tests which dialect we want to use for things X-Git-Tag: rel_0_7b1~8 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=33eae4a1405b1968ad486bfe3aefee7f7d631128;p=thirdparty%2Fsqlalchemy%2Fsqlalchemy.git make it more explicit in tests which dialect we want to use for things --- diff --git a/test/dialect/test_postgresql.py b/test/dialect/test_postgresql.py index 424e8b5d9c..5d67e19216 100644 --- a/test/dialect/test_postgresql.py +++ b/test/dialect/test_postgresql.py @@ -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 = \ diff --git a/test/engine/test_reflection.py b/test/engine/test_reflection.py index e23633802b..a83c332cb0 100644 --- a/test/engine/test_reflection.py +++ b/test/engine/test_reflection.py @@ -1133,6 +1133,7 @@ def _drop_views(con, schema=None): class ReverseCasingReflectTest(TestBase, AssertsCompiledSQL): + __dialect__ = 'default' @testing.requires.denormalized_names def setup(self): diff --git a/test/ext/test_compiler.py b/test/ext/test_compiler.py index 116b0f2293..eaa46cc28d 100644 --- a/test/ext/test_compiler.py +++ b/test/ext/test_compiler.py @@ -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): diff --git a/test/ext/test_hybrid.py b/test/ext/test_hybrid.py index 201d3821f6..cab1c90bb3 100644 --- a/test/ext/test_hybrid.py +++ b/test/ext/test_hybrid.py @@ -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() diff --git a/test/lib/testing.py b/test/lib/testing.py index 36a8c8d1a4..bf852de7cd 100644 --- a/test/lib/testing.py +++ b/test/lib/testing.py @@ -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: diff --git a/test/sql/test_case_statement.py b/test/sql/test_case_statement.py index 97220d4dd9..4bb9cf0fc0 100644 --- a/test/sql/test_case_statement.py +++ b/test/sql/test_case_statement.py @@ -7,6 +7,7 @@ from sqlalchemy.sql import table, column class CaseTest(TestBase, AssertsCompiledSQL): + __dialect__ = 'default' @classmethod def setup_class(cls): diff --git a/test/sql/test_compiler.py b/test/sql/test_compiler.py index 4ede563204..b060fef5b0 100644 --- a/test/sql/test_compiler.py +++ b/test/sql/test_compiler.py @@ -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," diff --git a/test/sql/test_constraints.py b/test/sql/test_constraints.py index f4791c0bde..1c13a0ec7a 100644 --- a/test/sql/test_constraints.py +++ b/test/sql/test_constraints.py @@ -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(), diff --git a/test/sql/test_functions.py b/test/sql/test_functions.py index b0106b21ba..98d8d7a970 100644 --- a/test/sql/test_functions.py +++ b/test/sql/test_functions.py @@ -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')): diff --git a/test/sql/test_generative.py b/test/sql/test_generative.py index c6f5dc05ef..088162c8a6 100644 --- a/test/sql/test_generative.py +++ b/test/sql/test_generative.py @@ -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 diff --git a/test/sql/test_quote.py b/test/sql/test_quote.py index 2aa5086c62..50adad7512 100644 --- a/test/sql/test_quote.py +++ b/test/sql/test_quote.py @@ -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 diff --git a/test/sql/test_types.py b/test/sql/test_types.py index 52db03d769..2262831952 100644 --- a/test/sql/test_types.py +++ b/test/sql/test_types.py @@ -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