diff options
author | Raymond Hettinger <python@rcn.com> | 2009-01-27 09:56:30 (GMT) |
---|---|---|
committer | Raymond Hettinger <python@rcn.com> | 2009-01-27 09:56:30 (GMT) |
commit | d17ad8d6386c446763554d61d777ee65ea68e97a (patch) | |
tree | dad0e93e119c51c8d2d3eb29cdad0ce3403c9e84 /Lib/test/test_itertools.py | |
parent | eb508ad8cfe7b6595152bbfdb68799d19064f1e8 (diff) | |
download | cpython-d17ad8d6386c446763554d61d777ee65ea68e97a.zip cpython-d17ad8d6386c446763554d61d777ee65ea68e97a.tar.gz cpython-d17ad8d6386c446763554d61d777ee65ea68e97a.tar.bz2 |
Stronger tests for combinatoric relationships.
Diffstat (limited to 'Lib/test/test_itertools.py')
-rw-r--r-- | Lib/test/test_itertools.py | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/Lib/test/test_itertools.py b/Lib/test/test_itertools.py index affad7f..1b1fe09 100644 --- a/Lib/test/test_itertools.py +++ b/Lib/test/test_itertools.py @@ -285,11 +285,15 @@ class TestBasicOps(unittest.TestCase): perm = list(permutations(s, r)) comb = list(combinations(s, r)) + self.assertEquals(len(prod), len(s)**r) + self.assertEquals(prod, sorted(set(prod))) # prod in lexicographic order without repeats self.assertEquals(cwr, [t for t in prod if sorted(t)==list(t)]) # cwr: prods which are sorted self.assertEquals(perm, [t for t in prod if len(set(t))==r]) # perm: prods with no dups self.assertEqual(comb, [t for t in perm if sorted(t)==list(t)]) # comb: perms that are sorted self.assertEqual(comb, [t for t in cwr if len(set(t))==r]) # comb: cwrs without dups - self.assertEqual(set(comb), set(cwr) & set(perm)) # comb: both a cwr and a perm + self.assertEqual(comb, list(filter(set(cwr).__contains__, perm))) # comb: perm that is a cwr + self.assertEqual(comb, list(filter(set(perm).__contains__, cwr))) # comb: cwr that is a perm + self.assertEqual(comb, sorted(set(cwr) & set(perm))) # comb: both a cwr and a perm def test_compress(self): self.assertEqual(list(compress('ABCDEF', [1,0,1,0,1,1])), list('ACEF')) |