From: Raymond Hettinger Date: Tue, 27 Jan 2009 13:26:35 +0000 (+0000) Subject: Add more tests for the powerset() recipe. X-Git-Tag: v2.7a1~2184 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=560f9a8a9004ba0a2ee064e9ad83f413d091b2fa;p=python Add more tests for the powerset() recipe. --- diff --git a/Lib/test/test_itertools.py b/Lib/test/test_itertools.py index f6a9975b33..1ba43f7d18 100644 --- a/Lib/test/test_itertools.py +++ b/Lib/test/test_itertools.py @@ -1491,6 +1491,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']