From: Mike Bayer Date: Sun, 21 Feb 2010 21:26:11 +0000 (+0000) Subject: clean up some skips, added skip for sqlite + python2 X-Git-Tag: rel_0_6beta2~165 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=b3f1513eafefc9bad1a36d58661f88cc84536125;p=thirdparty%2Fsqlalchemy%2Fsqlalchemy.git clean up some skips, added skip for sqlite + python2 --- diff --git a/lib/sqlalchemy/test/noseplugin.py b/lib/sqlalchemy/test/noseplugin.py index c47ed464e5..2ba6f751d5 100644 --- a/lib/sqlalchemy/test/noseplugin.py +++ b/lib/sqlalchemy/test/noseplugin.py @@ -112,6 +112,7 @@ class NoseSQLAlchemy(Plugin): def __should_skip_for(self, cls): if hasattr(cls, '__requires__'): def test_suite(): return 'ok' + test_suite.__name__ = cls.__name__ for requirement in cls.__requires__: check = getattr(requires, requirement) if check(test_suite)() != 'ok': @@ -124,6 +125,7 @@ class NoseSQLAlchemy(Plugin): print "'%s' unsupported on DB implementation '%s'" % ( cls.__class__.__name__, testing.db.name) return True + if getattr(cls, '__only_on__', None): spec = testing.db_spec(*util.to_list(cls.__only_on__)) if not spec(testing.db): @@ -137,6 +139,7 @@ class NoseSQLAlchemy(Plugin): print "'%s' skipped by %s" % ( cls.__class__.__name__, c.__name__) return True + for rule in getattr(cls, '__excluded_on__', ()): if testing._is_excluded(*rule): print "'%s' unsupported on DB %s version %s" % ( diff --git a/lib/sqlalchemy/test/requires.py b/lib/sqlalchemy/test/requires.py index 1ae6f7d7d4..c97e6f5bbb 100644 --- a/lib/sqlalchemy/test/requires.py +++ b/lib/sqlalchemy/test/requires.py @@ -13,6 +13,7 @@ from testing import \ skip_if import testing +import sys def deferrable_constraints(fn): """Target database must support derferable constraints.""" @@ -111,7 +112,10 @@ def savepoints(fn): def denormalized_names(fn): """Target database must have 'denormalized', i.e. UPPERCASE as case insensitive names.""" - return skip_if(lambda: not testing.db.dialect.requires_name_normalize)(fn) + return skip_if( + lambda: not testing.db.dialect.requires_name_normalize, + "Backend does not require denomralized names." + )(fn) def schemas(fn): """Target database must support external schemas, and have one named 'test_schema'.""" @@ -186,3 +190,26 @@ def unicode_ddl(fn): exclude('mysql', '<', (4, 1, 1), 'no unicode connection support'), ) +def python2(fn): + return _chain_decorators_on( + fn, + skip_if( + lambda: sys.version_info >= (3,), + "Python version 2.xx is required." + ) + ) + +def _has_sqlite(): + from sqlalchemy import create_engine + try: + e = create_engine('sqlite://') + return True + except ImportError: + return False + +def sqlite(fn): + return _chain_decorators_on( + fn, + skip_if(lambda: not _has_sqlite()) + ) + diff --git a/lib/sqlalchemy/test/testing.py b/lib/sqlalchemy/test/testing.py index 599d79aeb4..31a271a03d 100644 --- a/lib/sqlalchemy/test/testing.py +++ b/lib/sqlalchemy/test/testing.py @@ -308,13 +308,18 @@ def _server_version(bind=None): def skip_if(predicate, reason=None): """Skip a test if predicate is true.""" reason = reason or predicate.__name__ + carp = _should_carp_about_exclusion(reason) + def decorate(fn): fn_name = fn.__name__ def maybe(*args, **kw): if predicate(): msg = "'%s' skipped on DB %s version '%s': %s" % ( fn_name, config.db.name, _server_version(), reason) - raise SkipTest(msg) + print msg + if carp: + print >> sys.stderr, msg + return True else: return fn(*args, **kw) return function_named(maybe, fn_name) diff --git a/test/ext/test_sqlsoup.py b/test/ext/test_sqlsoup.py index 718c27a2ad..86344eb7a6 100644 --- a/test/ext/test_sqlsoup.py +++ b/test/ext/test_sqlsoup.py @@ -9,19 +9,8 @@ import datetime class SQLSoupTest(TestBase): - __skip_if__ = (lambda: not SQLSoupTest._has_sqlite(),) + __requires__ = ('sqlite', ) - @classmethod - def _has_sqlite(cls): - try: - import sqlite3 - except ImportError: - try: - import pysqlite2 - except ImportError: - return False - return True - @classmethod def setup_class(cls): global engine diff --git a/test/orm/test_pickled.py b/test/orm/test_pickled.py index a734ad7794..d801ad0293 100644 --- a/test/orm/test_pickled.py +++ b/test/orm/test_pickled.py @@ -282,6 +282,8 @@ class CustomSetupTeardownTest(_fixtures.FixtureTest): class UnpickleSA05Test(_fixtures.FixtureTest): """test loading picklestrings from SQLA 0.5.""" + __requires__ = ('python2',) + @testing.resolve_artifact_names def test_one(self): mapper(User, users, properties={