[Python-checkins] r69013 - python/branches/py3k/Lib/test/test_itertools.py
raymond.hettinger
python-checkins at python.org
Tue Jan 27 10:56:30 CET 2009
Author: raymond.hettinger
Date: Tue Jan 27 10:56:30 2009
New Revision: 69013
Log:
Stronger tests for combinatoric relationships.
Modified:
python/branches/py3k/Lib/test/test_itertools.py
Modified: python/branches/py3k/Lib/test/test_itertools.py
==============================================================================
--- python/branches/py3k/Lib/test/test_itertools.py (original)
+++ python/branches/py3k/Lib/test/test_itertools.py Tue Jan 27 10:56:30 2009
@@ -285,11 +285,15 @@
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'))
More information about the Python-checkins
mailing list