summaryrefslogtreecommitdiff
path: root/test/sql
diff options
context:
space:
mode:
authorMike Bayer <mike_mp@zzzcomputing.com>2014-03-03 15:55:17 -0500
committerMike Bayer <mike_mp@zzzcomputing.com>2014-03-03 15:55:17 -0500
commitea05a2321819405020ead5184770d39a0b7948da (patch)
tree1f28366cba2c6c8d4614d0e91a404013137bcd37 /test/sql
parentbf89ca2e10ff1c38e76f78e2d11d7858a50df547 (diff)
downloadsqlalchemy-ea05a2321819405020ead5184770d39a0b7948da.tar.gz
- Support has been added for pytest to run tests. This runner
is currently being supported in addition to nose, and will likely be preferred to nose going forward. The nose plugin system used by SQLAlchemy has been split out so that it works under pytest as well. There are no plans to drop support for nose at the moment and we hope that the test suite itself can continue to remain as agnostic of testing platform as possible. See the file README.unittests.rst for updated information on running tests with pytest. The test plugin system has also been enhanced to support running tests against mutiple database URLs at once, by specifying the ``--db`` and/or ``--dburi`` flags multiple times. This does not run the entire test suite for each database, but instead allows test cases that are specific to certain backends make use of that backend as the test is run. When using pytest as the test runner, the system will also run specific test suites multiple times, once for each database, particularly those tests within the "dialect suite". The plan is that the enhanced system will also be used by Alembic, and allow Alembic to run migration operation tests against multiple backends in one run, including third-party backends not included within Alembic itself. Third party dialects and extensions are also encouraged to standardize on SQLAlchemy's test suite as a basis; see the file README.dialects.rst for background on building out from SQLAlchemy's test platform.
Diffstat (limited to 'test/sql')
-rw-r--r--test/sql/test_functions.py13
-rw-r--r--test/sql/test_metadata.py12
-rw-r--r--test/sql/test_query.py5
-rw-r--r--test/sql/test_types.py30
-rw-r--r--test/sql/test_unicode.py48
5 files changed, 9 insertions, 99 deletions
diff --git a/test/sql/test_functions.py b/test/sql/test_functions.py
index 3e47e018b..7fd7058b5 100644
--- a/test/sql/test_functions.py
+++ b/test/sql/test_functions.py
@@ -215,7 +215,7 @@ class CompileTest(fixtures.TestBase, AssertsCompiledSQL):
sqltypes.DateTime)
]:
assert isinstance(fn(*args).type, type_), \
- "%s / %s" % (fn(), type_)
+ "%s / %r != %s" % (fn(), fn(*args).type, type_)
assert isinstance(func.concat("foo", "bar").type, sqltypes.String)
@@ -306,17 +306,6 @@ class ExecuteTest(fixtures.TestBase):
def tearDown(self):
pass
- @testing.uses_deprecated
- def test_standalone_execute(self):
- x = testing.db.func.current_date().execute().scalar()
- y = testing.db.func.current_date().select().execute().scalar()
- z = testing.db.func.current_date().scalar()
- assert (x == y == z) is True
-
- # ansi func
- x = testing.db.func.current_date()
- assert isinstance(x.type, Date)
- assert isinstance(x.execute().scalar(), datetime.date)
def test_conn_execute(self):
from sqlalchemy.sql.expression import FunctionElement
diff --git a/test/sql/test_metadata.py b/test/sql/test_metadata.py
index 5e256046d..ce95634fd 100644
--- a/test/sql/test_metadata.py
+++ b/test/sql/test_metadata.py
@@ -1249,16 +1249,6 @@ class UseExistingTest(fixtures.TablesTest):
go
)
- @testing.uses_deprecated
- def test_deprecated_useexisting(self):
- meta2 = self._useexisting_fixture()
- users = Table('users', meta2, Column('name', Unicode),
- autoload=True, useexisting=True)
- assert isinstance(users.c.name.type, Unicode)
- assert not users.quote
- users = Table('users', meta2, quote=True, autoload=True,
- useexisting=True)
- assert users.quote
def test_keep_plus_existing_raises(self):
meta2 = self._useexisting_fixture()
@@ -1268,7 +1258,7 @@ class UseExistingTest(fixtures.TablesTest):
extend_existing=True
)
- @testing.uses_deprecated
+ @testing.uses_deprecated()
def test_existing_plus_useexisting_raises(self):
meta2 = self._useexisting_fixture()
assert_raises(
diff --git a/test/sql/test_query.py b/test/sql/test_query.py
index c20087859..f65d44fc6 100644
--- a/test/sql/test_query.py
+++ b/test/sql/test_query.py
@@ -1179,11 +1179,6 @@ class QueryTest(fixtures.TestBase):
self.assert_(r.row == r['row'] == r[shadowed.c.row] == 'Without light there is no shadow')
self.assert_(r['_parent'] == 'Hidden parent')
self.assert_(r['_row'] == 'Hidden row')
- try:
- print(r._parent, r._row)
- self.fail('Should not allow access to private attributes')
- except AttributeError:
- pass # expected
finally:
shadowed.drop(checkfirst=True)
diff --git a/test/sql/test_types.py b/test/sql/test_types.py
index 3950b1a6a..887e76827 100644
--- a/test/sql/test_types.py
+++ b/test/sql/test_types.py
@@ -1351,36 +1351,6 @@ class ExpressionTest(fixtures.TestBase, AssertsExecutionResults, AssertsCompiled
expr = column('foo', CHAR) == "asdf"
eq_(expr.right.type.__class__, CHAR)
- @testing.uses_deprecated
- @testing.fails_on('firebird', 'Data type unknown on the parameter')
- @testing.fails_on('mssql', 'int is unsigned ? not clear')
- def test_operator_adapt(self):
- """test type-based overloading of operators"""
-
- # test string concatenation
- expr = test_table.c.data + "somedata"
- eq_(testing.db.execute(select([expr])).scalar(), "somedatasomedata")
-
- expr = test_table.c.id + 15
- eq_(testing.db.execute(select([expr])).scalar(), 16)
-
- # test custom operator conversion
- expr = test_table.c.avalue + 40
- assert expr.type.__class__ is test_table.c.avalue.type.__class__
-
- # value here is calculated as (250 - 40) / 10 = 21
- # because "40" is an integer, not an "avalue"
- eq_(testing.db.execute(select([expr.label('foo')])).scalar(), 21)
-
- expr = test_table.c.avalue + literal(40, type_=MyCustomType)
-
- # + operator converted to -
- # value is calculated as: (250 - (40 * 10)) / 10 == -15
- eq_(testing.db.execute(select([expr.label('foo')])).scalar(), -15)
-
- # this one relies upon anonymous labeling to assemble result
- # processing rules on the column.
- eq_(testing.db.execute(select([expr])).scalar(), -15)
def test_typedec_operator_adapt(self):
expr = test_table.c.bvalue + "hi"
diff --git a/test/sql/test_unicode.py b/test/sql/test_unicode.py
index 8a8cbd06c..0118b6a2b 100644
--- a/test/sql/test_unicode.py
+++ b/test/sql/test_unicode.py
@@ -4,8 +4,6 @@
from sqlalchemy import *
from sqlalchemy.testing import fixtures, engines, eq_
from sqlalchemy import testing
-from sqlalchemy.testing.engines import utf8_engine
-from sqlalchemy.sql import column
from sqlalchemy.testing.schema import Table, Column
from sqlalchemy.util import u, ue
@@ -14,11 +12,9 @@ class UnicodeSchemaTest(fixtures.TestBase):
@classmethod
def setup_class(cls):
- global unicode_bind, metadata, t1, t2, t3
+ global metadata, t1, t2, t3
- unicode_bind = utf8_engine()
-
- metadata = MetaData(unicode_bind)
+ metadata = MetaData(testing.db)
t1 = Table(u('unitable1'), metadata,
Column(u('méil'), Integer, primary_key=True),
Column(ue('\u6e2c\u8a66'), Integer),
@@ -68,9 +64,7 @@ class UnicodeSchemaTest(fixtures.TestBase):
@classmethod
def teardown_class(cls):
- global unicode_bind
metadata.drop_all()
- del unicode_bind
def test_insert(self):
t1.insert().execute({u('méil'):1, ue('\u6e2c\u8a66'):5})
@@ -85,20 +79,20 @@ class UnicodeSchemaTest(fixtures.TestBase):
assert t3.select().execute().fetchall() == [(1, 5, 1, 1)]
def test_reflect(self):
- t1.insert().execute({u('méil'):2, ue('\u6e2c\u8a66'):7})
- t2.insert().execute({u('a'):2, u('b'):2})
+ t1.insert().execute({u('méil'): 2, ue('\u6e2c\u8a66'): 7})
+ t2.insert().execute({u('a'): 2, u('b'): 2})
t3.insert().execute({ue('\u6e2c\u8a66_id'): 2,
ue('unitable1_\u6e2c\u8a66'): 7,
u('Unitéble2_b'): 2,
ue('\u6e2c\u8a66_self'): 2})
- meta = MetaData(unicode_bind)
+ meta = MetaData(testing.db)
tt1 = Table(t1.name, meta, autoload=True)
tt2 = Table(t2.name, meta, autoload=True)
tt3 = Table(t3.name, meta, autoload=True)
- tt1.insert().execute({u('méil'):1, ue('\u6e2c\u8a66'):5})
- tt2.insert().execute({u('méil'):1, ue('\u6e2c\u8a66'):1})
+ tt1.insert().execute({u('méil'): 1, ue('\u6e2c\u8a66'): 5})
+ tt2.insert().execute({u('méil'): 1, ue('\u6e2c\u8a66'): 1})
tt3.insert().execute({ue('\u6e2c\u8a66_id'): 1,
ue('unitable1_\u6e2c\u8a66'): 5,
u('Unitéble2_b'): 1,
@@ -111,8 +105,6 @@ class UnicodeSchemaTest(fixtures.TestBase):
self.assert_(tt3.select(order_by=desc(ue('\u6e2c\u8a66_id'))).
execute().fetchall() ==
[(2, 7, 2, 2), (1, 5, 1, 1)])
- meta.drop_all()
- metadata.create_all()
def test_repr(self):
@@ -128,29 +120,3 @@ class UnicodeSchemaTest(fixtures.TestBase):
"Column('\\u6e2c\\u8a66_id', Integer(), table=<\u6e2c\u8a66>), "
"schema=None)"))
-class EscapesDefaultsTest(fixtures.TestBase):
- def test_default_exec(self):
- metadata = MetaData(testing.db)
- t1 = Table('t1', metadata,
- Column('special_col', Integer, Sequence('special_col'), primary_key=True),
- Column('data', String(50)) # to appease SQLite without DEFAULT VALUES
- )
- metadata.create_all()
-
- try:
- engine = metadata.bind
-
- # reset the identifier preparer, so that we can force it to cache
- # a unicode identifier
- engine.dialect.identifier_preparer = engine.dialect.preparer(engine.dialect)
- select([column('special_col')]).select_from(t1).execute().close()
- assert isinstance(engine.dialect.identifier_preparer.format_sequence(Sequence('special_col')), str)
-
- # 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')
- finally:
- metadata.drop_all()
-
-