[Python-checkins] python/dist/src/Lib/test test_copy.py,1.6,1.7

gvanrossum@users.sourceforge.net gvanrossum@users.sourceforge.net
Tue, 18 Feb 2003 17:19:30 -0800


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

Modified Files:
	test_copy.py 
Log Message:
Use __reduce_ex__ in copy.py.  The test_*copy_cant() tests are simpler again.


Index: test_copy.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/test/test_copy.py,v
retrieving revision 1.6
retrieving revision 1.7
diff -C2 -d -r1.6 -r1.7
*** test_copy.py	7 Feb 2003 17:53:23 -0000	1.6
--- test_copy.py	19 Feb 2003 01:19:28 -0000	1.7
***************
*** 47,50 ****
--- 47,60 ----
          y = copy.copy(x)
  
+     def test_copy_reduce_ex(self):
+         class C(object):
+             def __reduce_ex__(self, proto):
+                 return ""
+             def __reduce__(self):
+                 raise test_support.TestFailed, "shouldn't call this"
+         x = C()
+         y = copy.copy(x)
+         self.assert_(y is x)
+ 
      def test_copy_reduce(self):
          class C(object):
***************
*** 56,66 ****
  
      def test_copy_cant(self):
!         class Meta(type):
              def __getattribute__(self, name):
!                 if name == "__reduce__":
                      raise AttributeError, name
                  return object.__getattribute__(self, name)
-         class C:
-             __metaclass__ = Meta
          x = C()
          self.assertRaises(copy.Error, copy.copy, x)
--- 66,74 ----
  
      def test_copy_cant(self):
!         class C(object):
              def __getattribute__(self, name):
!                 if name.startswith("__reduce"):
                      raise AttributeError, name
                  return object.__getattribute__(self, name)
          x = C()
          self.assertRaises(copy.Error, copy.copy, x)
***************
*** 210,213 ****
--- 218,231 ----
          y = copy.deepcopy(x)
  
+     def test_deepcopy_reduce_ex(self):
+         class C(object):
+             def __reduce_ex__(self, proto):
+                 return ""
+             def __reduce__(self):
+                 raise test_support.TestFailed, "shouldn't call this"
+         x = C()
+         y = copy.deepcopy(x)
+         self.assert_(y is x)
+ 
      def test_deepcopy_reduce(self):
          class C(object):
***************
*** 219,229 ****
  
      def test_deepcopy_cant(self):
!         class Meta(type):
              def __getattribute__(self, name):
!                 if name == "__reduce__":
                      raise AttributeError, name
                  return object.__getattribute__(self, name)
-         class C:
-             __metaclass__ = Meta
          x = C()
          self.assertRaises(copy.Error, copy.deepcopy, x)
--- 237,245 ----
  
      def test_deepcopy_cant(self):
!         class C(object):
              def __getattribute__(self, name):
!                 if name.startswith("__reduce"):
                      raise AttributeError, name
                  return object.__getattribute__(self, name)
          x = C()
          self.assertRaises(copy.Error, copy.deepcopy, x)