]> granicus.if.org Git - python/commitdiff
Add more tests for the powerset() recipe.
authorRaymond Hettinger <python@rcn.com>
Tue, 27 Jan 2009 13:29:43 +0000 (13:29 +0000)
committerRaymond Hettinger <python@rcn.com>
Tue, 27 Jan 2009 13:29:43 +0000 (13:29 +0000)
Lib/test/test_itertools.py

index 01409b3a0f11c58c584eb40c44cc9cfd5f1da748..f69ad26bbdecea851b23c6c3319586564403a83c 100644 (file)
@@ -1512,6 +1512,12 @@ perform as purported.
 >>> list(powerset([1,2,3]))
 [(), (1,), (2,), (3,), (1, 2), (1, 3), (2, 3), (1, 2, 3)]
 
+>>> all(len(list(powerset(range(n)))) == 2**n for n in range(18))
+True
+
+>>> list(powerset('abcde')) == sorted(sorted(set(powerset('abcde'))), key=len)
+True
+
 >>> list(unique_everseen('AAAABBBCCDAABBB'))
 ['A', 'B', 'C', 'D']