[pypy-svn] pypy default: Add a test for itertools.permutations().
arigo
commits-noreply at bitbucket.org
Tue Jan 25 17:47:51 CET 2011
Author: Armin Rigo <arigo at tunes.org>
Branch:
Changeset: r41303:a1e45048de2c
Date: 2011-01-22 17:16 +0100
http://bitbucket.org/pypy/pypy/changeset/a1e45048de2c/
Log: Add a test for itertools.permutations().
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
@@ -768,6 +768,35 @@
assert prod.next() == ()
raises (StopIteration, prod.next)
+ def test_permutations(self):
+ from itertools import permutations
+ assert list(permutations('ABCD', 2)) == [
+ ('A', 'B'),
+ ('A', 'C'),
+ ('A', 'D'),
+ ('B', 'A'),
+ ('B', 'C'),
+ ('B', 'D'),
+ ('C', 'A'),
+ ('C', 'B'),
+ ('C', 'D'),
+ ('D', 'A'),
+ ('D', 'B'),
+ ('D', 'C'),
+ ]
+ assert list(permutations(range(3))) == [
+ (0, 1, 2),
+ (0, 2, 1),
+ (1, 0, 2),
+ (1, 2, 0),
+ (2, 0, 1),
+ (2, 1, 0),
+ ]
+ assert list(permutations([])) == [()]
+ assert list(permutations([], 0)) == [()]
+ assert list(permutations([], 1)) == []
+ assert list(permutations(range(3), 4)) == []
+
class AppTestItertools27:
def setup_class(cls):
More information about the Pypy-commit
mailing list