Commits

Ned Batchelder committed a0ef155

Add assertGreater to our arsenal.

Comments (0)

Files changed (2)

test/backunittest.py

                 msg = msg or ('%r found in %r' % (member, container))
                 self.fail(msg)
 
+    if _need('assertGreater'):
+        def assertGreater(self, a, b, msg=None):
+            """Assert that `a` is greater than `b`."""
+            if not a > b:
+                msg = msg or ('%r not greater than %r' % (a, b))
+                self.fail(msg)
+
     if _need('assertRaisesRegexp'):
         def assertRaisesRegexp(self, excClass, regexp, callobj, *args, **kw):
             """ Just like unittest.TestCase.assertRaises,

test/test_testing.py

         self.assertNotIn("abc", ["x", "xabc"])
         self.assertNotIn("abc", {'x':'abc'})
 
+    def test_assert_greater(self):
+        self.assertGreater(10, 9)
+        self.assertGreater("xyz", "abc")
+        self.assertRaises(AssertionError, self.assertGreater, 9, 10)
+        self.assertRaises(AssertionError, self.assertGreater, 10, 10)
+        self.assertRaises(AssertionError, self.assertGreater, "abc", "xyz")
+        self.assertRaises(AssertionError, self.assertGreater, "xyz", "xyz")
+
 
 class CoverageTestTest(CoverageTest):
     """Test the methods in `CoverageTest`."""