summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_zipfile/_itertools.py
diff options
context:
space:
mode:
Diffstat (limited to 'Lib/test/test_zipfile/_itertools.py')
-rw-r--r--Lib/test/test_zipfile/_itertools.py29
1 files changed, 29 insertions, 0 deletions
diff --git a/Lib/test/test_zipfile/_itertools.py b/Lib/test/test_zipfile/_itertools.py
index 559f3f1..74f01fe 100644
--- a/Lib/test/test_zipfile/_itertools.py
+++ b/Lib/test/test_zipfile/_itertools.py
@@ -1,3 +1,32 @@
+import itertools
+
+
+# from jaraco.itertools 6.3.0
+class Counter:
+ """
+ Wrap an iterable in an object that stores the count of items
+ that pass through it.
+
+ >>> items = Counter(range(20))
+ >>> items.count
+ 0
+ >>> values = list(items)
+ >>> items.count
+ 20
+ """
+
+ def __init__(self, i):
+ self.count = 0
+ self.iter = zip(itertools.count(1), i)
+
+ def __iter__(self):
+ return self
+
+ def __next__(self):
+ self.count, result = next(self.iter)
+ return result
+
+
# from more_itertools v8.13.0
def always_iterable(obj, base_type=(str, bytes)):
if obj is None: