Files
RustPython/extra_tests/snippets/builtin_zip.py
Rex Ledesma 4e2e0b41c6 chore: add ruff format --check (#5774)
* chore: add `ruff format --check`

* fix tests
2025-05-12 14:20:01 +09:00

29 lines
617 B
Python

assert list(zip(["a", "b", "c"], range(3), [9, 8, 7, 99])) == [
("a", 0, 9),
("b", 1, 8),
("c", 2, 7),
]
assert list(zip(["a", "b", "c"])) == [("a",), ("b",), ("c",)]
assert list(zip()) == []
assert list(zip(*zip(["a", "b", "c"], range(1, 4)))) == [("a", "b", "c"), (1, 2, 3)]
# test infinite iterator
class Counter(object):
def __init__(self, counter=0):
self.counter = counter
def __next__(self):
self.counter += 1
return self.counter
def __iter__(self):
return self
it = zip(Counter(), Counter(3))
assert next(it) == (1, 4)
assert next(it) == (2, 5)