]> git.ipfire.org Git - thirdparty/sqlalchemy/sqlalchemy.git/commitdiff
added 'supports', 'unsupports' decorators to unittests so that they can all pass...
authorMike Bayer <mike_mp@zzzcomputing.com>
Sat, 29 Apr 2006 16:42:37 +0000 (16:42 +0000)
committerMike Bayer <mike_mp@zzzcomputing.com>
Sat, 29 Apr 2006 16:42:37 +0000 (16:42 +0000)
test/defaults.py
test/inheritance.py
test/objectstore.py
test/selectresults.py
test/testbase.py

index 096355826fa4a9a185903f15f8af29b5365a513c..8d848f4c5e13e4f553e22d8804fac4fc9c59befa 100644 (file)
@@ -131,7 +131,8 @@ class SequenceTest(PersistTest):
         )
         
         cartitems.create()
-
+    
+    @testbase.supported('postgres', 'oracle')
     def testsequence(self):
         cartitems.insert().execute(description='hi')
         cartitems.insert().execute(description='there')
@@ -140,6 +141,7 @@ class SequenceTest(PersistTest):
         cartitems.select().execute().fetchall()
    
    
+    @testbase.supported('postgres', 'oracle')
     def teststandalone(self):
         s = Sequence("my_sequence", engine=db)
         s.create()
@@ -149,6 +151,7 @@ class SequenceTest(PersistTest):
         finally:
             s.drop()
     
+    @testbase.supported('postgres', 'oracle')
     def teststandalone2(self):
         x = cartitems.c.cart_id.sequence.execute()
         self.assert_(1 <= x <= 4)
index 94784416160708963675e5587536272f205acd0c..8b683b8ffb94219a9094350376150f085352c6f9 100644 (file)
@@ -384,7 +384,9 @@ class InheritTest5(testbase.AssertMixin):
         # shouldnt throw exception
         products = mapper(Product, product, inherits=contents)
     
+    
     def testbackref(self):
+        """this test is currently known to fail in the 0.1 series of SQLAlchemy, pending the resolution of [ticket:154]"""
         class ContentType(object): pass
         class Content(object): pass
         class Product(Content): pass
index 4e61d08f0ce6c7c08e2b9516f488c11922b04fe2..9ec6ca7e207d9442366071d6809179dce98200b5 100644 (file)
@@ -143,7 +143,8 @@ class SessionTest(AssertMixin):
         trans.commit()
         self.assert_(name_of(7) != name1, msg="user_name should not be %s" % name1)
         self.assert_(name_of(8) != name2, msg="user_name should not be %s" % name2)
-
+    
+    @testbase.unsupported('sqlite')
     def test_true_nested(self):
         """tests creating a new Session inside a database transaction, in 
         conjunction with an engine-level nested transaction, which uses
@@ -185,7 +186,8 @@ class VersioningTest(AssertMixin):
         version_table.delete().execute()
         objectstore.clear()
         clear_mappers()
-        
+    
+    @testbase.unsupported('mysql')
     def testbasic(self):
         class Foo(object):pass
         assign_mapper(Foo, version_table, version_id_col=version_table.c.version_id)
@@ -287,6 +289,8 @@ class PKTest(AssertMixin):
     def setUp(self):
         objectstore.clear()
         clear_mappers()
+        
+    @testbase.unsupported('sqlite')
     def testprimarykey(self):
         class Entry(object):
             pass
index 6a3d9dd4d0402e1002de9049ab5ba85b3c1d13e0..2e603580acdb2b72215d176aa9391b9a9bfa81ee 100644 (file)
@@ -42,8 +42,14 @@ class SelectResultsTest(PersistTest):
         assert self.res.count() == 100
         assert self.res.filter(foo.c.bar<30).min(foo.c.bar) == 0
         assert self.res.filter(foo.c.bar<30).max(foo.c.bar) == 29
+
+    @testbase.unsupported('mysql')
+    def test_aggregate_1(self):
         # this one fails in mysql as the result comes back as a string
         assert self.res.filter(foo.c.bar<30).sum(foo.c.bar) == 435
+
+    @testbase.unsupported('postgres', 'mysql')
+    def test_aggregate_2(self):
         # this one fails with postgres, the floating point comparison fails
         assert self.res.filter(foo.c.bar<30).avg(foo.c.bar) == 14.5
 
index 923ed7de993693d90f38851d0531f1c0721b4ac6..8ef63ef2784974b30d20e28e78f3be257a2fa2ca 100644 (file)
@@ -59,13 +59,44 @@ def parse_argv():
         db = engine.create_engine(db_uri, echo=echo, default_ordering=True, **opts)
     db = EngineAssert(db)
 
+def unsupported(*dbs):
+    """a decorator that marks a test as unsupported by one or more database implementations"""
+    def decorate(func):
+        name = db.name
+        for d in dbs:
+            if d == name:
+                def lala(self):
+                    echo_text("'" + func.__name__ + "' unsupported on DB implementation '" + name + "'")
+                lala.__name__ = func.__name__
+                return lala
+        else:
+            return func
+    return decorate
+
+def supported(*dbs):
+    """a decorator that marks a test as supported by one or more database implementations"""
+    def decorate(func):
+        name = db.name
+        for d in dbs:
+            if d == name:
+                return func
+        else:
+            def lala(self):
+                echo_text("'" + func.__name__ + "' unsupported on DB implementation '" + name + "'")
+            lala.__name__ = func.__name__
+            return lala
+    return decorate
+
+def echo_text(text):
+    print text
+        
 class PersistTest(unittest.TestCase):
     """persist base class, provides default setUpAll, tearDownAll and echo functionality"""
     def __init__(self, *args, **params):
         unittest.TestCase.__init__(self, *args, **params)
     def echo(self, text):
         if echo:
-            print text
+            echo_text(text)
     def setUpAll(self):
         pass
     def tearDownAll(self):