Add class name to StorageTestCase failure reporting
authorW. Trevor King <wking@drexel.edu>
Mon, 18 Jan 2010 17:46:08 +0000 (12:46 -0500)
committerW. Trevor King <wking@drexel.edu>
Mon, 18 Jan 2010 17:46:08 +0000 (12:46 -0500)
libbe/storage/base.py

index 10649a8ef00667c90045b07d1c64227a84b208f4..202305b66a4bcf07ba3a3a61d8e8850bde6ea2d1 100644 (file)
@@ -533,6 +533,23 @@ if TESTING == True:
             super(StorageTestCase, self).__init__(*args, **kwargs)
             self.dirname = None
 
+        # this class will be the basis of tests for several classes,
+        # so make sure we print the name of the class we're dealing with.
+        def fail(self, msg=None):
+            """Fail immediately, with the given message."""
+            raise self.failureException, \
+                '(%s) %s' % (self.Class.__name__, msg)
+
+        def failIf(self, expr, msg=None):
+            "Fail the test if the expression is true."
+            if expr: raise self.failureException, \
+                '(%s) %s' % (self.Class.__name__, msg)
+
+        def failUnless(self, expr, msg=None):
+            """Fail the test unless the expression is true."""
+            if not expr: raise self.failureException, \
+                '(%s) %s' % (self.Class.__name__, msg)
+
         def setUp(self):
             """Set up test fixtures for Storage test case."""
             super(StorageTestCase, self).setUp()