diff options
author | Mike Bayer <mike_mp@zzzcomputing.com> | 2013-04-21 17:18:49 -0400 |
---|---|---|
committer | Mike Bayer <mike_mp@zzzcomputing.com> | 2013-04-21 17:18:49 -0400 |
commit | 3aff498e4a96eda06f09f09f98e73e135719b388 (patch) | |
tree | f1ca2029cfd147478447d3cb98bae587a8ccb3c2 /lib/sqlalchemy/testing | |
parent | 1f6528ed8581ba63721bdc2a0593a5d39b9c27e0 (diff) | |
parent | fbcdba12f88d88c509fc34eb8aab3f501d1b705b (diff) | |
download | sqlalchemy-3aff498e4a96eda06f09f09f98e73e135719b388.tar.gz |
merge into cymysql branch...
Diffstat (limited to 'lib/sqlalchemy/testing')
-rw-r--r-- | lib/sqlalchemy/testing/assertsql.py | 2 | ||||
-rw-r--r-- | lib/sqlalchemy/testing/plugin/noseplugin.py | 8 | ||||
-rw-r--r-- | lib/sqlalchemy/testing/profiling.py | 4 | ||||
-rw-r--r-- | lib/sqlalchemy/testing/runner.py | 10 | ||||
-rw-r--r-- | lib/sqlalchemy/testing/schema.py | 27 | ||||
-rw-r--r-- | lib/sqlalchemy/testing/suite/test_insert.py | 4 | ||||
-rw-r--r-- | lib/sqlalchemy/testing/suite/test_reflection.py | 10 | ||||
-rw-r--r-- | lib/sqlalchemy/testing/util.py | 3 |
8 files changed, 45 insertions, 23 deletions
diff --git a/lib/sqlalchemy/testing/assertsql.py b/lib/sqlalchemy/testing/assertsql.py index 864ce5b4d..0e250f356 100644 --- a/lib/sqlalchemy/testing/assertsql.py +++ b/lib/sqlalchemy/testing/assertsql.py @@ -174,6 +174,8 @@ class CompiledSQL(SQLMatchRule): params = self.params if not isinstance(params, list): params = [params] + else: + params = list(params) all_params = list(params) all_received = list(_received_parameters) while params: diff --git a/lib/sqlalchemy/testing/plugin/noseplugin.py b/lib/sqlalchemy/testing/plugin/noseplugin.py index 4ce76363e..5bd7ff3cd 100644 --- a/lib/sqlalchemy/testing/plugin/noseplugin.py +++ b/lib/sqlalchemy/testing/plugin/noseplugin.py @@ -215,11 +215,8 @@ def _set_table_options(options, file_config): @post def _reverse_topological(options, file_config): if options.reversetop: - from sqlalchemy.orm import unitofwork, session, mapper, dependency - from sqlalchemy.util import topological - from sqlalchemy.testing.util import RandomSet - topological.set = unitofwork.set = session.set = mapper.set = \ - dependency.set = RandomSet + from sqlalchemy.orm.util import randomize_unitofwork + randomize_unitofwork() def _requirements_opt(options, opt_str, value, parser): @@ -361,7 +358,6 @@ class NoseSQLAlchemy(Plugin): The class being examined by the selector """ - if not issubclass(cls, fixtures.TestBase): return False elif cls.__name__.startswith('_'): diff --git a/lib/sqlalchemy/testing/profiling.py b/lib/sqlalchemy/testing/profiling.py index ae9d176b7..19a9731be 100644 --- a/lib/sqlalchemy/testing/profiling.py +++ b/lib/sqlalchemy/testing/profiling.py @@ -14,11 +14,12 @@ import pstats import time import collections from .. import util + try: import cProfile except ImportError: cProfile = None -from ..util.compat import jython, pypy, win32 +from ..util import jython, pypy, win32, update_wrapper _current_test = None @@ -210,7 +211,6 @@ class ProfileStatsFile(object): profile_f.write("%s %s %s\n" % (test_key, platform_key, c)) profile_f.close() -from sqlalchemy.util.compat import update_wrapper def function_call_count(variance=0.05): diff --git a/lib/sqlalchemy/testing/runner.py b/lib/sqlalchemy/testing/runner.py index 6ec73d7c8..2bdbaebd1 100644 --- a/lib/sqlalchemy/testing/runner.py +++ b/lib/sqlalchemy/testing/runner.py @@ -31,3 +31,13 @@ import nose def main(): nose.main(addplugins=[NoseSQLAlchemy()]) + +def setup_py_test(): + """Runner to use for the 'test_suite' entry of your setup.py. + + Prevents any name clash shenanigans from the command line + argument "test" that the "setup.py test" command sends + to nose. + + """ + nose.main(addplugins=[NoseSQLAlchemy()], argv=['runner']) diff --git a/lib/sqlalchemy/testing/schema.py b/lib/sqlalchemy/testing/schema.py index ad233ec22..325d74f1e 100644 --- a/lib/sqlalchemy/testing/schema.py +++ b/lib/sqlalchemy/testing/schema.py @@ -66,18 +66,27 @@ def Column(*args, **kw): col = schema.Column(*args, **kw) if 'test_needs_autoincrement' in test_opts and \ - kw.get('primary_key', False) and \ - exclusions.against('firebird', 'oracle'): - def add_seq(c, tbl): - c._init_items( - schema.Sequence(_truncate_name( - config.db.dialect, tbl.name + '_' + c.name + '_seq'), - optional=True) - ) - event.listen(col, 'after_parent_attach', add_seq, propagate=True) + kw.get('primary_key', False): + + # allow any test suite to pick up on this + col.info['test_needs_autoincrement'] = True + + # hardcoded rule for firebird, oracle; this should + # be moved out + if exclusions.against('firebird', 'oracle'): + def add_seq(c, tbl): + c._init_items( + schema.Sequence(_truncate_name( + config.db.dialect, tbl.name + '_' + c.name + '_seq'), + optional=True) + ) + event.listen(col, 'after_parent_attach', add_seq, propagate=True) return col + + + def _truncate_name(dialect, name): if len(name) > dialect.max_identifier_length: return name[0:max(dialect.max_identifier_length - 6, 0)] + \ diff --git a/lib/sqlalchemy/testing/suite/test_insert.py b/lib/sqlalchemy/testing/suite/test_insert.py index 66aa1ecfa..a00fde312 100644 --- a/lib/sqlalchemy/testing/suite/test_insert.py +++ b/lib/sqlalchemy/testing/suite/test_insert.py @@ -33,7 +33,7 @@ class LastrowidTest(fixtures.TablesTest): row = conn.execute(table.select()).first() eq_( row, - (1, "some data") + (config.db.dialect.default_sequence_base, "some data") ) def test_autoincrement_on_insert(self): @@ -132,7 +132,7 @@ class ReturningTest(fixtures.TablesTest): row = conn.execute(table.select()).first() eq_( row, - (1, "some data") + (config.db.dialect.default_sequence_base, "some data") ) @classmethod diff --git a/lib/sqlalchemy/testing/suite/test_reflection.py b/lib/sqlalchemy/testing/suite/test_reflection.py index 5beed6aad..7cae48572 100644 --- a/lib/sqlalchemy/testing/suite/test_reflection.py +++ b/lib/sqlalchemy/testing/suite/test_reflection.py @@ -87,8 +87,10 @@ class ComponentReflectionTest(fixtures.TablesTest): test_needs_fk=True, ) - cls.define_index(metadata, users) - cls.define_views(metadata, schema) + if testing.requires.index_reflection.enabled: + cls.define_index(metadata, users) + if testing.requires.view_reflection.enabled: + cls.define_views(metadata, schema) @classmethod def define_index(cls, metadata, users): @@ -121,12 +123,14 @@ class ComponentReflectionTest(fixtures.TablesTest): self.assert_('test_schema' in insp.get_schema_names()) + @testing.requires.schema_reflection def test_dialect_initialize(self): engine = engines.testing_engine() assert not hasattr(engine.dialect, 'default_schema_name') inspect(engine) assert hasattr(engine.dialect, 'default_schema_name') + @testing.requires.schema_reflection def test_get_default_schema_name(self): insp = inspect(testing.db) eq_(insp.default_schema_name, testing.db.dialect.default_schema_name) @@ -157,6 +161,7 @@ class ComponentReflectionTest(fixtures.TablesTest): self._test_get_table_names() @testing.requires.table_reflection + @testing.requires.foreign_key_constraint_reflection def test_get_table_names_fks(self): self._test_get_table_names(order_by='foreign_key') @@ -261,6 +266,7 @@ class ComponentReflectionTest(fixtures.TablesTest): self._test_get_pk_constraint() @testing.requires.table_reflection + @testing.requires.primary_key_constraint_reflection @testing.requires.schemas def test_get_pk_constraint_with_schema(self): self._test_get_pk_constraint(schema='test_schema') diff --git a/lib/sqlalchemy/testing/util.py b/lib/sqlalchemy/testing/util.py index 2592c341e..d9ff14eaf 100644 --- a/lib/sqlalchemy/testing/util.py +++ b/lib/sqlalchemy/testing/util.py @@ -1,6 +1,5 @@ from ..util import jython, pypy, defaultdict, decorator -from ..util.compat import decimal - +import decimal import gc import time import random |