summaryrefslogtreecommitdiffstats
path: root/Lib
diff options
context:
space:
mode:
Diffstat (limited to 'Lib')
-rw-r--r--Lib/test/test_enumerate.py1
-rw-r--r--Lib/test/test_iterlen.py12
-rw-r--r--Lib/test/test_itertools.py1
3 files changed, 13 insertions, 1 deletions
diff --git a/Lib/test/test_enumerate.py b/Lib/test/test_enumerate.py
index b6a18ee..e0a272e 100644
--- a/Lib/test/test_enumerate.py
+++ b/Lib/test/test_enumerate.py
@@ -144,6 +144,7 @@ class TestReversed(unittest.TestCase):
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)
diff --git a/Lib/test/test_iterlen.py b/Lib/test/test_iterlen.py
index b51263d..1770de2 100644
--- a/Lib/test/test_iterlen.py
+++ b/Lib/test/test_iterlen.py
@@ -43,12 +43,22 @@ enumerate(iter('abc')).
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):
diff --git a/Lib/test/test_itertools.py b/Lib/test/test_itertools.py
index 5db128c..635d156 100644
--- a/Lib/test/test_itertools.py
+++ b/Lib/test/test_itertools.py
@@ -670,6 +670,7 @@ class TestVariousIteratorArgs(unittest.TestCase):
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))