]> git.ipfire.org Git - thirdparty/sqlalchemy/sqlalchemy.git/commitdiff
clean up some skips, added skip for sqlite + python2
authorMike Bayer <mike_mp@zzzcomputing.com>
Sun, 21 Feb 2010 21:26:11 +0000 (21:26 +0000)
committerMike Bayer <mike_mp@zzzcomputing.com>
Sun, 21 Feb 2010 21:26:11 +0000 (21:26 +0000)
lib/sqlalchemy/test/noseplugin.py
lib/sqlalchemy/test/requires.py
lib/sqlalchemy/test/testing.py
test/ext/test_sqlsoup.py
test/orm/test_pickled.py

index c47ed464e51cbf2a11024ff8e45f1746d3a7979d..2ba6f751d5f1be5c9d6a7f7dede5702fa859caf2 100644 (file)
@@ -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" % (
index 1ae6f7d7d4b1d3dc51edf006e30063f829bf63f6..c97e6f5bbbedcbcf1629be701b2d777bc6b803eb 100644 (file)
@@ -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())
+    )
+
index 599d79aeb4c5b00278de175529b529658d41e40e..31a271a03d3a3ba60f8f9cb9a1ddd25141b6d186 100644 (file)
@@ -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)
index 718c27a2ada700b07833052179b0455e32844f2d..86344eb7a6eb4206df0bd704abaa4c4cc7deb965 100644 (file)
@@ -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
index a734ad7794ac5bb260a8e0bd9c65c57ac38dba80..d801ad029311ed661420d2b9295f52f01c061b43 100644 (file)
@@ -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={