[Python-checkins] python/dist/src/Lib/test test_enumerate.py, 1.16, 1.17 test_iterlen.py, 1.2, 1.3 test_itertools.py, 1.39, 1.40

rhettinger@users.sourceforge.net rhettinger at users.sourceforge.net
Sat Sep 24 23:23:08 CEST 2005


Update of /cvsroot/python/python/dist/src/Lib/test
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv7585/Lib/test

Modified Files:
	test_enumerate.py test_iterlen.py test_itertools.py 
Log Message:
Convert iterator __len__() methods to a private API.

Index: test_enumerate.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/test/test_enumerate.py,v
retrieving revision 1.16
retrieving revision 1.17
diff -u -d -r1.16 -r1.17
--- test_enumerate.py	17 Jul 2005 23:16:18 -0000	1.16
+++ test_enumerate.py	24 Sep 2005 21:23:05 -0000	1.17
@@ -144,6 +144,7 @@
 
     def test_len(self):
         # This is an implementation detail, not an interface requirement
+        from test.test_iterlen import len
         for s in ('hello', tuple('hello'), list('hello'), xrange(5)):
             self.assertEqual(len(reversed(s)), len(s))
             r = reversed(s)

Index: test_iterlen.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/test/test_iterlen.py,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -d -r1.2 -r1.3
--- test_iterlen.py	8 Jul 2004 04:22:19 -0000	1.2
+++ test_iterlen.py	24 Sep 2005 21:23:05 -0000	1.3
@@ -43,12 +43,22 @@
 
 import unittest
 from test import test_support
-from itertools import repeat, count
+from itertools import repeat
 from collections import deque
 from UserList import UserList
+from __builtin__ import len as _len
 
 n = 10
 
+def len(obj):
+    try:
+        return _len(obj)
+    except TypeError:
+        try:
+            return obj._length_cue()
+        except AttributeError:
+            raise TypeError
+
 class TestInvariantWithoutMutations(unittest.TestCase):
 
     def test_invariant(self):

Index: test_itertools.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/test/test_itertools.py,v
retrieving revision 1.39
retrieving revision 1.40
diff -u -d -r1.39 -r1.40
--- test_itertools.py	27 Mar 2005 20:11:44 -0000	1.39
+++ test_itertools.py	24 Sep 2005 21:23:05 -0000	1.40
@@ -670,6 +670,7 @@
 class LengthTransparency(unittest.TestCase):
 
     def test_repeat(self):
+        from test.test_iterlen import len
         self.assertEqual(len(repeat(None, 50)), 50)
         self.assertRaises(TypeError, len, repeat(None))
 



More information about the Python-checkins mailing list