[Python-checkins] python/dist/src/Lib/test pickletester.py,1.48,1.49
tim_one@users.sourceforge.net
tim_one@users.sourceforge.net
Thu, 13 Feb 2003 10:42:03 -0800
Update of /cvsroot/python/python/dist/src/Lib/test
In directory sc8-pr-cvs1:/tmp/cvs-serv18574/Lib/test
Modified Files:
pickletester.py
Log Message:
Added a simple NEWOBJ test. This is in the pickle-only part of the
test for now (cPickle can't yet produce NEWOBJ).
Index: pickletester.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/test/pickletester.py,v
retrieving revision 1.48
retrieving revision 1.49
diff -C2 -d -r1.48 -r1.49
*** pickletester.py 13 Feb 2003 15:44:40 -0000 1.48
--- pickletester.py 13 Feb 2003 18:42:00 -0000 1.49
***************
*** 725,728 ****
--- 725,738 ----
class TempAbstractPickleTests(unittest.TestCase):
+ def test_simple_newobj(self):
+ x = object.__new__(SimpleNewObj) # avoid __init__
+ x.abc = 666
+ for proto in protocols:
+ s = self.dumps(x, proto)
+ self.assertEqual(opcode_in_pickle(pickle.NEWOBJ, s), proto >= 2)
+ y = self.loads(s) # will raise TypeError if __init__ called
+ self.assertEqual(y.abc, 666)
+ self.assertEqual(x.__dict__, y.__dict__)
+
def test_newobj_list_slots(self):
x = SlotList([1, 2, 3])
***************
*** 771,774 ****
--- 781,789 ----
class SlotList(MyList):
__slots__ = ["foo"]
+
+ class SimpleNewObj(object):
+ def __init__(self, a, b, c):
+ # raise an error, to make sure this isn't called
+ raise TypeError("SimpleNewObj.__init__() didn't expect to get called")
class AbstractPickleModuleTests(unittest.TestCase):