keyword: use Python 2/3-agnostic set notation in reduce_keywords doctest
authorW. Trevor King <wking@tremily.us>
Mon, 12 Nov 2012 01:35:08 +0000 (20:35 -0500)
committerW. Trevor King <wking@tremily.us>
Mon, 12 Nov 2012 01:35:08 +0000 (20:35 -0500)
Python 2.7 prints sets as "set([1, 2])", but Python 3.2 prints them as
"{1, 2}".  Avoid having to chose by showing that the result of
reduce_keywords() is a set, and then printing the elements in a list.

pym/gentoolkit/keyword.py

index 17b3472b150978d9b3ef51250e0533fbea6c8a1d..a234116895cf8c5dbc5b01217e01ce397f0fdfed 100644 (file)
@@ -95,8 +95,11 @@ def reduce_keywords(keywords):
        """Reduce a list of keywords to a unique set of stable keywords.
 
        Example usage:
-               >>> reduce_keywords(['~amd64', 'x86', '~x86'])
-               set(['amd64', 'x86'])
+               >>> kw = reduce_keywords(['~amd64', 'x86', '~x86'])
+               >>> isinstance(kw, set)
+               True
+               >>> sorted(kw)
+               ['amd64', 'x86']
 
        @type keywords: array
        @rtype: set