[Python-checkins] python/dist/src/Lib/test pickletester.py,1.33,1.34

tim_one@users.sourceforge.net tim_one@users.sourceforge.net
Sun, 02 Feb 2003 08:09:07 -0800


Update of /cvsroot/python/python/dist/src/Lib/test
In directory sc8-pr-cvs1:/tmp/cvs-serv6130/Lib/test

Modified Files:
	pickletester.py 
Log Message:
Add cPickle support for PROTO.  Duplicated PROTO/LONG1/LONG4 code in
the hitherto unknown (to me) noload() cPickle function, which is (a)
something we don't test at all, and (b) pickle.py doesn't have.


Index: pickletester.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/test/pickletester.py,v
retrieving revision 1.33
retrieving revision 1.34
diff -C2 -d -r1.33 -r1.34
*** pickletester.py	2 Feb 2003 07:51:32 -0000	1.33
--- pickletester.py	2 Feb 2003 16:09:05 -0000	1.34
***************
*** 1,3 ****
--- 1,5 ----
  import unittest
+ import pickle
+ 
  from test.test_support import TestFailed, have_unicode, TESTFN
  
***************
*** 297,300 ****
--- 299,321 ----
      # Tests for protocol 2
  
+     def test_proto(self):
+         build_none = pickle.NONE + pickle.STOP
+         for proto in protocols:
+             expected = build_none
+             if proto >= 2:
+                 expected = pickle.PROTO + chr(proto) + expected
+             p = self.dumps(None, proto)
+             self.assertEqual(p, expected)
+ 
+         oob = protocols[-1] + 1     # a future protocol
+         badpickle = pickle.PROTO + chr(oob) + build_none
+         try:
+             self.loads(badpickle)
+         except ValueError, detail:
+             self.failUnless(str(detail).startswith(
+                                             "unsupported pickle protocol"))
+         else:
+             self.fail("expected bad protocol number to raise ValueError")
+ 
      def test_long1(self):
          x = 12345678910111213141516178920L
***************
*** 315,319 ****
          d = (1, 2, 3)
          e = (1, 2, 3, 4)
!         for proto in 0, 1, 2:
              for x in a, b, c, d, e:
                  s = self.dumps(x, proto)
--- 336,340 ----
          d = (1, 2, 3)
          e = (1, 2, 3, 4)
!         for proto in protocols:
              for x in a, b, c, d, e:
                  s = self.dumps(x, proto)
***************
*** 322,326 ****
  
      def test_singletons(self):
!         for proto in 0, 1, 2:
              for x in None, False, True:
                  s = self.dumps(x, proto)
--- 343,347 ----
  
      def test_singletons(self):
!         for proto in protocols:
              for x in None, False, True:
                  s = self.dumps(x, proto)