[pypy-svn] r39741 - in pypy/branch/rope-branch/pypy: module/marshal/test objspace/std

arigo at codespeak.net arigo at codespeak.net
Fri Mar 2 18:45:01 CET 2007


Author: arigo
Date: Fri Mar  2 18:44:59 2007
New Revision: 39741

Modified:
   pypy/branch/rope-branch/pypy/module/marshal/test/test_marshal.py
   pypy/branch/rope-branch/pypy/objspace/std/marshal_impl.py
Log:
(cfbolz, arigo)

More precise marshal/unmarshal tests - check for the exact type of the
final object.

Fix the corresponding marshalling bug for Rope.


Modified: pypy/branch/rope-branch/pypy/module/marshal/test/test_marshal.py
==============================================================================
--- pypy/branch/rope-branch/pypy/module/marshal/test/test_marshal.py	(original)
+++ pypy/branch/rope-branch/pypy/module/marshal/test/test_marshal.py	Fri Mar  2 18:44:59 2007
@@ -12,12 +12,12 @@
         print "case: %-30s   func=None" % (case, )
         s = marshal.dumps(case)
         x = marshal.loads(s)
-        assert x == case
+        assert x == case and type(x) is type(case)
         f = StringIO.StringIO()
         marshal.dump(case, f)
         f.seek(0)
         x = marshal.load(f)
-        assert x == case
+        assert x == case and type(x) is type(case)
 
     def test_False(self):
         import sys
@@ -31,12 +31,12 @@
         print "case: %-30s   func=False" % (case, )
         s = marshal.dumps(case)
         x = marshal.loads(s)
-        assert x == case
+        assert x == case and type(x) is type(case)
         f = StringIO.StringIO()
         marshal.dump(case, f)
         f.seek(0)
         x = marshal.load(f)
-        assert x == case
+        assert x == case and type(x) is type(case)
 
     def test_True(self):
         import sys
@@ -50,12 +50,12 @@
         print "case: %-30s   func=True" % (case, )
         s = marshal.dumps(case)
         x = marshal.loads(s)
-        assert x == case
+        assert x == case and type(x) is type(case)
         f = StringIO.StringIO()
         marshal.dump(case, f)
         f.seek(0)
         x = marshal.load(f)
-        assert x == case
+        assert x == case and type(x) is type(case)
 
     def test_StopIteration(self):
         import sys
@@ -69,12 +69,12 @@
         print "case: %-30s   func=StopIteration" % (case, )
         s = marshal.dumps(case)
         x = marshal.loads(s)
-        assert x == case
+        assert x == case and type(x) is type(case)
         f = StringIO.StringIO()
         marshal.dump(case, f)
         f.seek(0)
         x = marshal.load(f)
-        assert x == case
+        assert x == case and type(x) is type(case)
 
     def test_Ellipsis(self):
         import sys
@@ -88,12 +88,12 @@
         print "case: %-30s   func=Ellipsis" % (case, )
         s = marshal.dumps(case)
         x = marshal.loads(s)
-        assert x == case
+        assert x == case and type(x) is type(case)
         f = StringIO.StringIO()
         marshal.dump(case, f)
         f.seek(0)
         x = marshal.load(f)
-        assert x == case
+        assert x == case and type(x) is type(case)
 
     def test_42(self):
         import sys
@@ -107,12 +107,12 @@
         print "case: %-30s   func=42" % (case, )
         s = marshal.dumps(case)
         x = marshal.loads(s)
-        assert x == case
+        assert x == case and type(x) is type(case)
         f = StringIO.StringIO()
         marshal.dump(case, f)
         f.seek(0)
         x = marshal.load(f)
-        assert x == case
+        assert x == case and type(x) is type(case)
 
     def test__minus_17(self):
         import sys
@@ -126,12 +126,12 @@
         print "case: %-30s   func=_minus_17" % (case, )
         s = marshal.dumps(case)
         x = marshal.loads(s)
-        assert x == case
+        assert x == case and type(x) is type(case)
         f = StringIO.StringIO()
         marshal.dump(case, f)
         f.seek(0)
         x = marshal.load(f)
-        assert x == case
+        assert x == case and type(x) is type(case)
 
     def test_sys_dot_maxint(self):
         import sys
@@ -145,12 +145,12 @@
         print "case: %-30s   func=sys_dot_maxint" % (case, )
         s = marshal.dumps(case)
         x = marshal.loads(s)
-        assert x == case
+        assert x == case and type(x) is type(case)
         f = StringIO.StringIO()
         marshal.dump(case, f)
         f.seek(0)
         x = marshal.load(f)
-        assert x == case
+        assert x == case and type(x) is type(case)
 
     def test__minus_1_dot_25(self):
         import sys
@@ -164,12 +164,12 @@
         print "case: %-30s   func=_minus_1_dot_25" % (case, )
         s = marshal.dumps(case)
         x = marshal.loads(s)
-        assert x == case
+        assert x == case and type(x) is type(case)
         f = StringIO.StringIO()
         marshal.dump(case, f)
         f.seek(0)
         x = marshal.load(f)
-        assert x == case
+        assert x == case and type(x) is type(case)
 
     def test__minus_1_dot_25__2(self):
         import sys
@@ -183,12 +183,12 @@
         print "case: %-30s   func=_minus_1_dot_25__2" % (case, )
         s = marshal.dumps(case, 2); assert len(s) in (9, 17)
         x = marshal.loads(s)
-        assert x == case
+        assert x == case and type(x) is type(case)
         f = StringIO.StringIO()
         marshal.dump(case, f)
         f.seek(0)
         x = marshal.load(f)
-        assert x == case
+        assert x == case and type(x) is type(case)
 
     def test_2_plus_5j(self):
         import sys
@@ -202,12 +202,12 @@
         print "case: %-30s   func=2_plus_5j" % (case, )
         s = marshal.dumps(case)
         x = marshal.loads(s)
-        assert x == case
+        assert x == case and type(x) is type(case)
         f = StringIO.StringIO()
         marshal.dump(case, f)
         f.seek(0)
         x = marshal.load(f)
-        assert x == case
+        assert x == case and type(x) is type(case)
 
     def test_2_plus_5j__2(self):
         import sys
@@ -221,12 +221,12 @@
         print "case: %-30s   func=2_plus_5j__2" % (case, )
         s = marshal.dumps(case, 2); assert len(s) in (9, 17)
         x = marshal.loads(s)
-        assert x == case
+        assert x == case and type(x) is type(case)
         f = StringIO.StringIO()
         marshal.dump(case, f)
         f.seek(0)
         x = marshal.load(f)
-        assert x == case
+        assert x == case and type(x) is type(case)
 
     def test_42L(self):
         import sys
@@ -240,12 +240,12 @@
         print "case: %-30s   func=42L" % (case, )
         s = marshal.dumps(case)
         x = marshal.loads(s)
-        assert x == case
+        assert x == case and type(x) is type(case)
         f = StringIO.StringIO()
         marshal.dump(case, f)
         f.seek(0)
         x = marshal.load(f)
-        assert x == case
+        assert x == case and type(x) is type(case)
 
     def test__minus_1234567890123456789012345678901234567890L(self):
         import sys
@@ -259,12 +259,12 @@
         print "case: %-30s   func=_minus_1234567890123456789012345678901234567890L" % (case, )
         s = marshal.dumps(case)
         x = marshal.loads(s)
-        assert x == case
+        assert x == case and type(x) is type(case)
         f = StringIO.StringIO()
         marshal.dump(case, f)
         f.seek(0)
         x = marshal.load(f)
-        assert x == case
+        assert x == case and type(x) is type(case)
 
     def test_hello_____not_interned(self):
         import sys
@@ -278,12 +278,12 @@
         print "case: %-30s   func=hello_____not_interned" % (case, )
         s = marshal.dumps(case)
         x = marshal.loads(s)
-        assert x == case
+        assert x == case and type(x) is type(case)
         f = StringIO.StringIO()
         marshal.dump(case, f)
         f.seek(0)
         x = marshal.load(f)
-        assert x == case
+        assert x == case and type(x) is type(case)
 
     def test__Quote_hello_Quote_(self):
         import sys
@@ -297,12 +297,12 @@
         print "case: %-30s   func=_Quote_hello_Quote_" % (case, )
         s = marshal.dumps(case)
         x = marshal.loads(s)
-        assert x == case
+        assert x == case and type(x) is type(case)
         f = StringIO.StringIO()
         marshal.dump(case, f)
         f.seek(0)
         x = marshal.load(f)
-        assert x == case
+        assert x == case and type(x) is type(case)
 
     def test__brace__ecarb_(self):
         import sys
@@ -316,12 +316,12 @@
         print "case: %-30s   func=_brace__ecarb_" % (case, )
         s = marshal.dumps(case)
         x = marshal.loads(s)
-        assert x == case
+        assert x == case and type(x) is type(case)
         f = StringIO.StringIO()
         marshal.dump(case, f)
         f.seek(0)
         x = marshal.load(f)
-        assert x == case
+        assert x == case and type(x) is type(case)
 
     def test__brace_1_comma__2_ecarb_(self):
         import sys
@@ -335,12 +335,12 @@
         print "case: %-30s   func=_brace_1_comma__2_ecarb_" % (case, )
         s = marshal.dumps(case)
         x = marshal.loads(s)
-        assert x == case
+        assert x == case and type(x) is type(case)
         f = StringIO.StringIO()
         marshal.dump(case, f)
         f.seek(0)
         x = marshal.load(f)
-        assert x == case
+        assert x == case and type(x) is type(case)
 
     def test__list__tsil_(self):
         import sys
@@ -354,12 +354,12 @@
         print "case: %-30s   func=_list__tsil_" % (case, )
         s = marshal.dumps(case)
         x = marshal.loads(s)
-        assert x == case
+        assert x == case and type(x) is type(case)
         f = StringIO.StringIO()
         marshal.dump(case, f)
         f.seek(0)
         x = marshal.load(f)
-        assert x == case
+        assert x == case and type(x) is type(case)
 
     def test__list_3_comma__4_tsil_(self):
         import sys
@@ -373,12 +373,12 @@
         print "case: %-30s   func=_list_3_comma__4_tsil_" % (case, )
         s = marshal.dumps(case)
         x = marshal.loads(s)
-        assert x == case
+        assert x == case and type(x) is type(case)
         f = StringIO.StringIO()
         marshal.dump(case, f)
         f.seek(0)
         x = marshal.load(f)
-        assert x == case
+        assert x == case and type(x) is type(case)
 
     def test__dict__tcid_(self):
         import sys
@@ -392,12 +392,12 @@
         print "case: %-30s   func=_dict__tcid_" % (case, )
         s = marshal.dumps(case)
         x = marshal.loads(s)
-        assert x == case
+        assert x == case and type(x) is type(case)
         f = StringIO.StringIO()
         marshal.dump(case, f)
         f.seek(0)
         x = marshal.load(f)
-        assert x == case
+        assert x == case and type(x) is type(case)
 
     def test__dict_5_colon__6_comma__7_colon__8_tcid_(self):
         import sys
@@ -411,12 +411,12 @@
         print "case: %-30s   func=_dict_5_colon__6_comma__7_colon__8_tcid_" % (case, )
         s = marshal.dumps(case)
         x = marshal.loads(s)
-        assert x == case
+        assert x == case and type(x) is type(case)
         f = StringIO.StringIO()
         marshal.dump(case, f)
         f.seek(0)
         x = marshal.load(f)
-        assert x == case
+        assert x == case and type(x) is type(case)
 
     def test_func_dot_func_code(self):
         import sys
@@ -430,12 +430,12 @@
         print "case: %-30s   func=func_dot_func_code" % (case, )
         s = marshal.dumps(case)
         x = marshal.loads(s)
-        assert x == case
+        assert x == case and type(x) is type(case)
         f = StringIO.StringIO()
         marshal.dump(case, f)
         f.seek(0)
         x = marshal.load(f)
-        assert x == case
+        assert x == case and type(x) is type(case)
 
     def test_scopefunc_dot_func_code(self):
         import sys
@@ -449,12 +449,12 @@
         print "case: %-30s   func=scopefunc_dot_func_code" % (case, )
         s = marshal.dumps(case)
         x = marshal.loads(s)
-        assert x == case
+        assert x == case and type(x) is type(case)
         f = StringIO.StringIO()
         marshal.dump(case, f)
         f.seek(0)
         x = marshal.load(f)
-        assert x == case
+        assert x == case and type(x) is type(case)
 
     def test_u_quote_hello_quote_(self):
         import sys
@@ -468,12 +468,12 @@
         print "case: %-30s   func=u_quote_hello_quote_" % (case, )
         s = marshal.dumps(case)
         x = marshal.loads(s)
-        assert x == case
+        assert x == case and type(x) is type(case)
         f = StringIO.StringIO()
         marshal.dump(case, f)
         f.seek(0)
         x = marshal.load(f)
-        assert x == case
+        assert x == case and type(x) is type(case)
 
     def test_buffer_brace_hello_ecarb_(self):
         import sys
@@ -487,12 +487,12 @@
         print "case: %-30s   func=buffer_brace_hello_ecarb_" % (case, )
         s = marshal.dumps(case)
         x = marshal.loads(s)
-        assert x == case
+        assert x == case and type(x) is type(case)
         f = StringIO.StringIO()
         marshal.dump(case, f)
         f.seek(0)
         x = marshal.load(f)
-        assert x == case
+        assert x == case and type(x) is type(case)
 
     def test_buffer_brace_u_quote_unicode_comma__too_quote__ecarb_(self):
         import sys
@@ -506,12 +506,12 @@
         print "case: %-30s   func=buffer_brace_u_quote_unicode_comma__too_quote__ecarb_" % (case, )
         s = marshal.dumps(case)
         x = marshal.loads(s)
-        assert x == case
+        assert x == case and type(x) is type(case)
         f = StringIO.StringIO()
         marshal.dump(case, f)
         f.seek(0)
         x = marshal.load(f)
-        assert x == case
+        assert x == case and type(x) is type(case)
 
     def test_set_brace__ecarb_(self):
         import sys
@@ -525,12 +525,12 @@
         print "case: %-30s   func=set_brace__ecarb_" % (case, )
         s = marshal.dumps(case)
         x = marshal.loads(s)
-        assert x == case
+        assert x == case and type(x) is type(case)
         f = StringIO.StringIO()
         marshal.dump(case, f)
         f.seek(0)
         x = marshal.load(f)
-        assert x == case
+        assert x == case and type(x) is type(case)
 
     def test_set_brace__list_1_comma__2_tsil__ecarb_(self):
         import sys
@@ -544,12 +544,12 @@
         print "case: %-30s   func=set_brace__list_1_comma__2_tsil__ecarb_" % (case, )
         s = marshal.dumps(case)
         x = marshal.loads(s)
-        assert x == case
+        assert x == case and type(x) is type(case)
         f = StringIO.StringIO()
         marshal.dump(case, f)
         f.seek(0)
         x = marshal.load(f)
-        assert x == case
+        assert x == case and type(x) is type(case)
 
     def test_frozenset_brace__ecarb_(self):
         import sys
@@ -563,12 +563,12 @@
         print "case: %-30s   func=frozenset_brace__ecarb_" % (case, )
         s = marshal.dumps(case)
         x = marshal.loads(s)
-        assert x == case
+        assert x == case and type(x) is type(case)
         f = StringIO.StringIO()
         marshal.dump(case, f)
         f.seek(0)
         x = marshal.load(f)
-        assert x == case
+        assert x == case and type(x) is type(case)
 
     def test_frozenset_brace__list_3_comma__4_tsil__ecarb_(self):
         import sys
@@ -582,12 +582,12 @@
         print "case: %-30s   func=frozenset_brace__list_3_comma__4_tsil__ecarb_" % (case, )
         s = marshal.dumps(case)
         x = marshal.loads(s)
-        assert x == case
+        assert x == case and type(x) is type(case)
         f = StringIO.StringIO()
         marshal.dump(case, f)
         f.seek(0)
         x = marshal.load(f)
-        assert x == case
+        assert x == case and type(x) is type(case)
 
 
 class AppTestMultiDict(object):
@@ -597,3 +597,8 @@
 
     test__dict__tcid_ = AppTestMarshal.test__dict__tcid_.im_func
     test__dict_5_colon__6_comma__7_colon__8_tcid_ = AppTestMarshal.test__dict_5_colon__6_comma__7_colon__8_tcid_.im_func
+
+class AppTestRope(AppTestMarshal):
+    def setup_class(cls):
+        from pypy.conftest import gettestobjspace
+        cls.space = gettestobjspace(**{"objspace.std.withrope": True})

Modified: pypy/branch/rope-branch/pypy/objspace/std/marshal_impl.py
==============================================================================
--- pypy/branch/rope-branch/pypy/objspace/std/marshal_impl.py	(original)
+++ pypy/branch/rope-branch/pypy/objspace/std/marshal_impl.py	Fri Mar  2 18:44:59 2007
@@ -28,6 +28,7 @@
 from pypy.objspace.std.dictmultiobject    import W_DictMultiObject
 from pypy.objspace.std.dictstrobject import W_DictStrObject
 from pypy.objspace.std.stringobject  import W_StringObject
+from pypy.objspace.std.ropeobject    import W_RopeObject
 from pypy.objspace.std.typeobject    import W_TypeObject
 from pypy.objspace.std.longobject    import W_LongObject
 from pypy.objspace.std.noneobject    import W_NoneObject
@@ -302,6 +303,8 @@
     else:
         m.atom_str(TYPE_STRING, s)
 
+marshal_w__Rope = marshal_w__String
+
 def unmarshal_String(space, u, tc):
     return space.wrap(u.get_str())
 register(TYPE_STRING, unmarshal_String)



More information about the Pypy-commit mailing list