summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rw-r--r--test/lib/profiles.txt7
-rw-r--r--test/lib/profiling.py3
-rw-r--r--test/sql/test_type_expressions.py61
-rw-r--r--test/sql/test_types.py13
4 files changed, 60 insertions, 24 deletions
diff --git a/test/lib/profiles.txt b/test/lib/profiles.txt
index 707ecb621..841609ece 100644
--- a/test/lib/profiles.txt
+++ b/test/lib/profiles.txt
@@ -26,7 +26,10 @@ test.aaa_profiling.test_compiler.CompileTest.test_insert 3.2_sqlite_pysqlite_noc
# TEST: test.aaa_profiling.test_compiler.CompileTest.test_select
+test.aaa_profiling.test_compiler.CompileTest.test_select 2.7_mysql_mysqldb_cextensions 133
+test.aaa_profiling.test_compiler.CompileTest.test_select 2.7_postgresql_psycopg2_cextensions 133
test.aaa_profiling.test_compiler.CompileTest.test_select 2.7_postgresql_psycopg2_nocextensions 133
+test.aaa_profiling.test_compiler.CompileTest.test_select 2.7_sqlite_pysqlite_cextensions 133
test.aaa_profiling.test_compiler.CompileTest.test_select 2.7_sqlite_pysqlite_nocextensions 133
# TEST: test.aaa_profiling.test_compiler.CompileTest.test_select_second_time
@@ -191,7 +194,10 @@ test.aaa_profiling.test_resultset.ExecutionTest.test_minimal_engine_execute 3.2_
# TEST: test.aaa_profiling.test_resultset.ResultSetTest.test_contains_doesnt_compile
+test.aaa_profiling.test_resultset.ResultSetTest.test_contains_doesnt_compile 2.7_mysql_mysqldb_cextensions 14
+test.aaa_profiling.test_resultset.ResultSetTest.test_contains_doesnt_compile 2.7_postgresql_psycopg2_cextensions 14
test.aaa_profiling.test_resultset.ResultSetTest.test_contains_doesnt_compile 2.7_postgresql_psycopg2_nocextensions 14
+test.aaa_profiling.test_resultset.ResultSetTest.test_contains_doesnt_compile 2.7_sqlite_pysqlite_cextensions 14
test.aaa_profiling.test_resultset.ResultSetTest.test_contains_doesnt_compile 2.7_sqlite_pysqlite_nocextensions 14
# TEST: test.aaa_profiling.test_resultset.ResultSetTest.test_string
@@ -234,6 +240,7 @@ test.aaa_profiling.test_zoomark.ZooMarkTest.test_profile_2_insert 3.2_postgresql
# TEST: test.aaa_profiling.test_zoomark.ZooMarkTest.test_profile_3_properties
+test.aaa_profiling.test_zoomark.ZooMarkTest.test_profile_3_properties 2.7_postgresql_psycopg2_cextensions 3302
test.aaa_profiling.test_zoomark.ZooMarkTest.test_profile_3_properties 2.7_postgresql_psycopg2_nocextensions 3526
# TEST: test.aaa_profiling.test_zoomark.ZooMarkTest.test_profile_4_expressions
diff --git a/test/lib/profiling.py b/test/lib/profiling.py
index 6ca28d462..e02c4ce46 100644
--- a/test/lib/profiling.py
+++ b/test/lib/profiling.py
@@ -229,6 +229,9 @@ def function_call_count(variance=0.05):
raise SkipTest("cProfile is not installed")
if not _profile_stats.has_stats() and not _profile_stats.write:
+ # run the function anyway, to support dependent tests
+ # (not a great idea but we have these in test_zoomark)
+ fn(*args, **kw)
raise SkipTest("No profiling stats available on this "
"platform for this function. Run tests with "
"--write-profiles to add statistics to %s for "
diff --git a/test/sql/test_type_expressions.py b/test/sql/test_type_expressions.py
index d64ee7f0e..1445ee4f9 100644
--- a/test/sql/test_type_expressions.py
+++ b/test/sql/test_type_expressions.py
@@ -1,4 +1,4 @@
-from sqlalchemy import Table, Column, String, func, MetaData, select
+from sqlalchemy import Table, Column, String, func, MetaData, select, TypeDecorator
from test.lib import fixtures, AssertsCompiledSQL, testing
from test.lib.testing import eq_
@@ -77,24 +77,7 @@ class SelectTest(fixtures.TestBase, AssertsCompiledSQL):
"test_table WHERE test_table.y = lower(:y_2)"
)
-class RoundTripTest(fixtures.TablesTest):
- @classmethod
- def define_tables(cls, metadata):
- class MyString(String):
- def bind_expression(self, bindvalue):
- return func.lower(bindvalue)
-
- def column_expression(self, col):
- return func.upper(col)
-
- Table(
- 'test_table',
- metadata,
- Column('x', String(50)),
- Column('y', MyString(50)
- )
- )
-
+class RoundTripTestBase(object):
def test_round_trip(self):
testing.db.execute(
self.tables.test_table.insert(),
@@ -150,8 +133,6 @@ class RoundTripTest(fixtures.TablesTest):
"Y1"
)
- @testing.fails_if(lambda: True, "still need to propagate "
- "result_map more effectively")
def test_targeting_individual_labels(self):
testing.db.execute(
self.tables.test_table.insert(),
@@ -166,6 +147,44 @@ class RoundTripTest(fixtures.TablesTest):
"Y1"
)
+class StringRoundTripTest(fixtures.TablesTest, RoundTripTestBase):
+ @classmethod
+ def define_tables(cls, metadata):
+ class MyString(String):
+ def bind_expression(self, bindvalue):
+ return func.lower(bindvalue)
+
+ def column_expression(self, col):
+ return func.upper(col)
+
+ Table(
+ 'test_table',
+ metadata,
+ Column('x', String(50)),
+ Column('y', MyString(50)
+ )
+ )
+
+
+class TypeDecRoundTripTest(fixtures.TablesTest, RoundTripTestBase):
+ @classmethod
+ def define_tables(cls, metadata):
+ class MyString(TypeDecorator):
+ impl = String
+ def bind_expression(self, bindvalue):
+ return func.lower(bindvalue)
+
+ def column_expression(self, col):
+ return func.upper(col)
+
+ Table(
+ 'test_table',
+ metadata,
+ Column('x', String(50)),
+ Column('y', MyString(50)
+ )
+ )
+
class ReturningTest(fixtures.TablesTest):
__requires__ = 'returning',
diff --git a/test/sql/test_types.py b/test/sql/test_types.py
index 279ae36a0..74047c7ca 100644
--- a/test/sql/test_types.py
+++ b/test/sql/test_types.py
@@ -441,6 +441,13 @@ class UserDefinedTest(fixtures.TablesTest, AssertsCompiledSQL):
[]
)
+ eq_(
+ testing.db.scalar(
+ select([type_coerce(literal('d1BIND_OUT'), MyType)])
+ ),
+ 'd1BIND_OUT'
+ )
+
@classmethod
def define_tables(cls, metadata):
class MyType(types.UserDefinedType):
@@ -1300,9 +1307,9 @@ class ExpressionTest(fixtures.TestBase, AssertsExecutionResults, AssertsCompiled
pass
# unknown type + integer, right hand bind
- # is an Integer
+ # coerces to given type
expr = column("foo", MyFoobarType) + 5
- assert expr.right.type._type_affinity is types.Integer
+ assert expr.right.type._type_affinity is MyFoobarType
# untyped bind - it gets assigned MyFoobarType
expr = column("foo", MyFoobarType) + bindparam("foo")
@@ -1321,7 +1328,7 @@ class ExpressionTest(fixtures.TestBase, AssertsExecutionResults, AssertsCompiled
assert expr.right.type._type_affinity is MyFoobarType
expr = column("foo", MyFoobarType) - datetime.date(2010, 8, 25)
- assert expr.right.type._type_affinity is types.Date
+ assert expr.right.type._type_affinity is MyFoobarType
def test_date_coercion(self):
from sqlalchemy.sql import column