[pypy-svn] r8176 - pypy/branch/src-pytest/pypy/objspace/test

pedronis at codespeak.net pedronis at codespeak.net
Sat Jan 8 19:09:58 CET 2005


Author: pedronis
Date: Sat Jan  8 19:09:58 2005
New Revision: 8176

Modified:
   pypy/branch/src-pytest/pypy/objspace/test/test_descriptor.py
   pypy/branch/src-pytest/pypy/objspace/test/test_traceobjspace.py
Log:
converted objspace/test tests



Modified: pypy/branch/src-pytest/pypy/objspace/test/test_descriptor.py
==============================================================================
--- pypy/branch/src-pytest/pypy/objspace/test/test_descriptor.py	(original)
+++ pypy/branch/src-pytest/pypy/objspace/test/test_descriptor.py	Sat Jan  8 19:09:58 2005
@@ -1,29 +1,25 @@
 import autopath
-from pypy.tool import testit
     
-class Test_Descriptor(testit.AppTestCase):
+class AppTest_Descriptor:
 
     def test_non_data_descr(self):
         class X(object):
             def f(self):
                 return 42
         x = X()
-        self.assertEquals(x.f(), 42)
+        assert x.f() == 42
         x.f = 43
-        self.assertEquals(x.f, 43)
+        assert x.f == 43
         del x.f
-        self.assertEquals(x.f(), 42)
+        assert x.f() == 42
 
     def test_member(self):
         import sys
-        self.assertEquals(sys.stdin.softspace, 0)
-        self.assertEquals(file.softspace.__get__(sys.stdin), 0)
+        assert sys.stdin.softspace == 0
+        assert file.softspace.__get__(sys.stdin) == 0
         sys.stdin.softspace = 1
-        self.assertEquals(sys.stdin.softspace, 1)
+        assert sys.stdin.softspace == 1
         file.softspace.__set__(sys.stdin, 0)
-        self.assertEquals(sys.stdin.softspace, 0)
-        self.assertRaises(TypeError, delattr, sys.stdin, 'softspace')
-        self.assertRaises(TypeError, file.softspace.__delete__, sys.stdin)
-
-if __name__ == '__main__':
-    testit.main()
+        assert sys.stdin.softspace == 0
+        raises(TypeError, delattr, sys.stdin, 'softspace')
+        raises(TypeError, file.softspace.__delete__, sys.stdin)

Modified: pypy/branch/src-pytest/pypy/objspace/test/test_traceobjspace.py
==============================================================================
--- pypy/branch/src-pytest/pypy/objspace/test/test_traceobjspace.py	(original)
+++ pypy/branch/src-pytest/pypy/objspace/test/test_traceobjspace.py	Sat Jan  8 19:09:58 2005
@@ -1,16 +1,14 @@
 import autopath
-from pypy.tool import testit
 from pypy.objspace import trace 
 from pypy.tool import pydis
 from pypy.interpreter import gateway 
     
-class Test_TraceObjSpace(testit.IntTestCase):
+class Test_TraceObjSpace:
 
-    def setUp(self):
-        self.space = testit.objspace()       
+    def setup_method(self,method):
         trace.create_trace_space(self.space)
         
-    def tearDown(self):
+    def teardown_method(self,method):
         self.space.reset_trace()
 
     def perform_trace(self, app_func):
@@ -24,7 +22,7 @@
 
     def test_traceobjspace_basic(self):
         tspace = self.space
-        self.assert_(tspace.is_true(tspace.w_builtins))
+        assert tspace.is_true(tspace.w_builtins)
         #for name, value in vars(self.space).items():
         #    if not name.startswith('_'):
         #        self.assert_(value is getattr(t, name))
@@ -35,21 +33,21 @@
             pass
         res = self.perform_trace(app_f)
         disresult = pydis.pydis(app_f)
-        self.assertEquals(disresult.bytecodes, list(res.getbytecodes()))
+        assert disresult.bytecodes == list(res.getbytecodes())
 
     def test_some_builtin1(self):
         def app_f():
             len([1,2,3,4,5])
         res = self.perform_trace(app_f)
         disresult = pydis.pydis(app_f)
-        self.assertEquals(len(disresult.bytecodes), len(list(res.getbytecodes())))
+        assert len(disresult.bytecodes) == len(list(res.getbytecodes()))
 
     def test_some_builtin2(self):
         def app_f(): 
             filter(None, []) # filter implemented in appspace -> has many more bytecodes        
         res = self.perform_trace(app_f)
         disresult = pydis.pydis(app_f)
-        self.failUnless(len(disresult.bytecodes) < len(list(res.getbytecodes())))
+        assert len(disresult.bytecodes) < len(list(res.getbytecodes()))
 
     def get_operation(self, iter, optype, name):
         for op in iter:
@@ -66,9 +64,6 @@
         ops = res.getoperations()
         op_start = self.get_operation(ops, trace.CallBegin, "add")
         args = [uw(x) for x in op_start.callinfo.args]
-        self.assertEquals(args, [1, 1])
+        assert args == [1, 1]
         op_end = self.get_operation(ops, trace.CallFinished, "add")        
-        self.assertEquals(uw(op_end.res), 2)
-
-if __name__ == '__main__':
-    testit.main()
+        assert uw(op_end.res) == 2



More information about the Pypy-commit mailing list