[pypy-svn] r8712 - pypy/dist/lib-python-2.3.4/test

ac at codespeak.net ac at codespeak.net
Sat Jan 29 14:32:39 CET 2005


Author: ac
Date: Sat Jan 29 14:32:39 2005
New Revision: 8712

Modified:
   pypy/dist/lib-python-2.3.4/test/pypy_unittest.py
Log:
Make our TestCase look more like unittest.TestCase


Modified: pypy/dist/lib-python-2.3.4/test/pypy_unittest.py
==============================================================================
--- pypy/dist/lib-python-2.3.4/test/pypy_unittest.py	(original)
+++ pypy/dist/lib-python-2.3.4/test/pypy_unittest.py	Sat Jan 29 14:32:39 2005
@@ -11,17 +11,54 @@
             assert x == y, msg 
         else: 
             assert x == y 
+
     def assertNotEqual(self, x, y, msg=None): 
         if msg: 
             assert x != y, msg 
         else: 
             assert x != y 
 
+    def failIfEqual(self, x, y, msg=None): 
+        if msg: 
+            assert not x == y, msg 
+        else: 
+            assert not x == y 
+
+    def failUnless(self, expr, msg=None):
+        if msg is None:
+            assert expr
+        else:
+            assert expr, msg
+
+    def failIf(self, expr, msg=None):
+        if msg is None:
+            assert not expr
+        else:
+            assert not expr, msg
+
+    def fail(self, msg):
+        assert False, msg
+        
     def assertRaises(self, exc, call, *args, **kwargs): 
         raises(exc, call, *args, **kwargs) 
 
+    def assertAlmostEqual(self, x, y, places07, msg=None):
+        if msg is None:
+            msg = '%r != %r within %r places' %(x, y, places)
+        assert round(y-x, places) == 0, msg
+
+    def assertNotAlmostEqual(self, x, y, places07, msg=None):
+        if msg is None:
+            msg = '%r == %r within %r places' %(x, y, places)
+        assert round(y-x, places) != 0, msg
+
     assertEquals = assertEqual 
     assertNotEquals = assertNotEqual 
+    failUnlessRaises = assertRaises
+    failUnlessEqual = assertEqual
+    failIfAlmostEqual = assertNotAlmostEqual
+    failUnlessAlmostEqual = assertAlmostEqual
+    
     def assert_(self, expr, msg=None): 
         if msg: 
             assert expr, msg 



More information about the Pypy-commit mailing list