Anonymous avatar Anonymous committed d59ea53

added merged-tests methods to subclass of testcase in testsupport,
used them in test_dictobject.

Comments (0)

Files changed (2)

pypy/objspace/std/test/test_dictobject.py

 from pypy.objspace.std.objspace import *
 
 
-class TestW_DictObject(unittest.TestCase):
+class TestW_DictObject(testsupport.TestCase_w):
 
     def setUp(self):
         self.space = StdObjSpace()
     def test_empty(self):
         space = self.space
         d = dobj.W_DictObject([])
-        self.failIf(space.is_true(d))
+        self.failIf_w(d)
 
     def test_nonempty(self):
         space = self.space

pypy/objspace/std/test/testsupport.py

 import sys, os
+import unittest
 
 testdir   = os.path.dirname(os.path.abspath(__file__))
 parentdir = os.path.dirname(testdir)
 rootdir   = os.path.dirname(os.path.dirname(parentdir))
 
 sys.path.insert(0, os.path.dirname(rootdir))
+
+class TestCase_w(unittest.TestCase):
+    """ enrich TestCase with wrapped-methods """
+
+    def failUnless_w(self, condition_w, msg=None):
+        condition = self.space.is_true(condition_w)
+        return self.failUnless(condition, msg)
+
+    def failIf_w(self, condition_w, msg=None):
+        condition = self.space.is_true(condition_w)
+        return self.failIf(condition, msg)
+
+    def assertEqual_w(self, first_w, second_w, msg=None):
+        condition_w = self.space.eq(first_w, second_w)
+        condition = self.space.is_true(condition_w)
+        return self.failUnless(condition, msg)
+
+    def assertNotEqual_w(self, first_w, second_w, msg=None):
+        condition_w = self.space.eq(first_w, second_w)
+        condition = self.space.is_true(condition_w)
+        return self.failIf(condition, msg)
+
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.