From: Mike Bayer Date: Wed, 9 Jul 2014 22:12:32 +0000 (-0400) Subject: - support __only_on__ and __backend__ at the same time X-Git-Tag: rel_0_9_7~48 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=3f08eece3f8b3876f4e5411849576c65250c181d;p=thirdparty%2Fsqlalchemy%2Fsqlalchemy.git - support __only_on__ and __backend__ at the same time Conflicts: test/dialect/mysql/test_types.py --- diff --git a/lib/sqlalchemy/testing/plugin/plugin_base.py b/lib/sqlalchemy/testing/plugin/plugin_base.py index 061848e271..a068272421 100644 --- a/lib/sqlalchemy/testing/plugin/plugin_base.py +++ b/lib/sqlalchemy/testing/plugin/plugin_base.py @@ -318,7 +318,7 @@ def want_class(cls): def generate_sub_tests(cls, module): if getattr(cls, '__backend__', False): - for cfg in config.Config.all_configs(): + for cfg in _possible_configs_for_cls(cls): name = "%s_%s_%s" % (cls.__name__, cfg.db.name, cfg.db.driver) subcls = type( name, @@ -370,8 +370,25 @@ def after_test(test): engines.testing_reaper._after_test_ctx() warnings.resetwarnings() -def _do_skips(cls): +def _possible_configs_for_cls(cls): all_configs = set(config.Config.all_configs()) + if cls.__unsupported_on__: + spec = exclusions.db_spec(*cls.__unsupported_on__) + for config_obj in list(all_configs): + if spec(config_obj): + all_configs.remove(config_obj) + + if getattr(cls, '__only_on__', None): + spec = exclusions.db_spec(*util.to_list(cls.__only_on__)) + for config_obj in list(all_configs): + if not spec(config_obj): + all_configs.remove(config_obj) + + + return all_configs + +def _do_skips(cls): + all_configs = _possible_configs_for_cls(cls) reasons = [] if hasattr(cls, '__requires__'): @@ -398,19 +415,6 @@ def _do_skips(cls): if all_configs.difference(non_preferred): all_configs.difference_update(non_preferred) - if cls.__unsupported_on__: - spec = exclusions.db_spec(*cls.__unsupported_on__) - for config_obj in list(all_configs): - if spec(config_obj): - all_configs.remove(config_obj) - - if getattr(cls, '__only_on__', None): - spec = exclusions.db_spec(*util.to_list(cls.__only_on__)) - for config_obj in list(all_configs): - if not spec(config_obj): - all_configs.remove(config_obj) - - if getattr(cls, '__skip_if__', False): for c in getattr(cls, '__skip_if__'): if c(): diff --git a/test/dialect/mysql/test_types.py b/test/dialect/mysql/test_types.py index b7d261a886..845eceae40 100644 --- a/test/dialect/mysql/test_types.py +++ b/test/dialect/mysql/test_types.py @@ -15,6 +15,8 @@ class TypesTest(fixtures.TestBase, AssertsExecutionResults, AssertsCompiledSQL): "Test MySQL column types" __dialect__ = mysql.dialect() + __only_on__ = 'mysql' + __backend__ = True def test_numeric(self): "Exercise type specification and options for numeric types." @@ -152,7 +154,6 @@ class TypesTest(fixtures.TestBase, AssertsExecutionResults, AssertsCompiledSQL): res ) - @testing.only_if('mysql') @testing.provide_metadata def test_precision_float_roundtrip(self): t = Table('t', self.metadata, @@ -290,7 +291,6 @@ class TypesTest(fixtures.TestBase, AssertsExecutionResults, AssertsCompiledSQL): ]: self.assert_compile(type_, expected) - @testing.only_if('mysql') @testing.exclude('mysql', '<', (5, 0, 5), 'a 5.0+ feature') @testing.fails_if( lambda: testing.against("mysql+oursql") and util.py3k, @@ -349,7 +349,6 @@ class TypesTest(fixtures.TestBase, AssertsExecutionResults, AssertsCompiledSQL): ]: self.assert_compile(type_, expected) - @testing.only_if('mysql') @testing.provide_metadata def test_boolean_roundtrip(self): bool_table = Table( @@ -447,7 +446,6 @@ class TypesTest(fixtures.TestBase, AssertsExecutionResults, AssertsCompiledSQL): ) - @testing.only_if('mysql') @testing.provide_metadata def test_timestamp_nullable(self): ts_table = Table('mysql_timestamp', self.metadata, @@ -514,7 +512,6 @@ class TypesTest(fixtures.TestBase, AssertsExecutionResults, AssertsCompiledSQL): datetime.time(8, 37, 35, 450) ) - @testing.only_if('mysql') @testing.provide_metadata def test_time_roundtrip(self): t = Table('mysql_time', self.metadata, @@ -524,7 +521,6 @@ class TypesTest(fixtures.TestBase, AssertsExecutionResults, AssertsCompiledSQL): t.insert().values(t1=datetime.time(8, 37, 35)).execute() eq_(select([t.c.t1]).scalar(), datetime.time(8, 37, 35)) - @testing.only_if('mysql') @testing.provide_metadata def test_year(self): """Exercise YEAR."""