Author: Armin Rigo <[email protected]>
Branch:
Changeset: r68858:0e43b0a21fe8
Date: 2014-01-22 18:39 +0100
http://bitbucket.org/pypy/pypy/changeset/0e43b0a21fe8/
Log: Some extra tests
diff --git a/pypy/module/itertools/test/test_itertools.py
b/pypy/module/itertools/test/test_itertools.py
--- a/pypy/module/itertools/test/test_itertools.py
+++ b/pypy/module/itertools/test/test_itertools.py
@@ -862,6 +862,28 @@
assert prod.next() == ()
raises (StopIteration, prod.next)
+ def test_product_powers_of_two(self):
+ from itertools import product
+ assert list(product()) == [()]
+ assert list(product('ab')) == [('a',), ('b',)]
+ assert list(product('ab', 'cd')) == [
+ ('a', 'c'), ('a', 'd'),
+ ('b', 'c'), ('b', 'd')]
+ assert list(product('ab', 'cd', 'ef')) == [
+ ('a', 'c', 'e'), ('a', 'c', 'f'),
+ ('a', 'd', 'e'), ('a', 'd', 'f'),
+ ('b', 'c', 'e'), ('b', 'c', 'f'),
+ ('b', 'd', 'e'), ('b', 'd', 'f')]
+
+ def test_product_empty_item(self):
+ from itertools import product
+ assert list(product('')) == []
+ assert list(product('ab', '')) == []
+ assert list(product('', 'cd')) == []
+ assert list(product('ab', 'cd', '')) == []
+ assert list(product('ab', '', 'ef')) == []
+ assert list(product('', 'cd', 'ef')) == []
+
def test_permutations(self):
from itertools import permutations
assert list(permutations('AB')) == [('A', 'B'), ('B', 'A')]
_______________________________________________
pypy-commit mailing list
[email protected]
https://mail.python.org/mailman/listinfo/pypy-commit