summaryrefslogtreecommitdiffstats
path: root/Lib
diff options
context:
space:
mode:
authorTim Peters <tim.peters@gmail.com>2003-03-01 23:33:34 (GMT)
committerTim Peters <tim.peters@gmail.com>2003-03-01 23:33:34 (GMT)
commit3ba491e6b1747707374e56fd9f0fb958b2aafcd5 (patch)
tree8cfd9676211655a58f1c736f43b2dd9558b311d8 /Lib
parentf421e81e4112809380542af378575756247eba00 (diff)
downloadcpython-3ba491e6b1747707374e56fd9f0fb958b2aafcd5.zip
cpython-3ba491e6b1747707374e56fd9f0fb958b2aafcd5.tar.gz
cpython-3ba491e6b1747707374e56fd9f0fb958b2aafcd5.tar.bz2
The doctest was printing Sets, but that's unreliable because set
elements get displayed in undefined dict order. Use a Set subclass instead (which arranges to sort the elements for display).
Diffstat (limited to 'Lib')
-rw-r--r--Lib/test/test_sets.py15
1 files changed, 9 insertions, 6 deletions
diff --git a/Lib/test/test_sets.py b/Lib/test/test_sets.py
index fc431cb..9223596 100644
--- a/Lib/test/test_sets.py
+++ b/Lib/test/test_sets.py
@@ -641,7 +641,10 @@ class TestCopyingNested(TestCopying):
libreftest = """
Example from the Library Reference: Doc/lib/libsets.tex
->>> from sets import Set
+>>> from sets import Set as Base # override _repr to get sorted output
+>>> class Set(Base):
+... def _repr(self):
+... return Base._repr(self, sorted=True)
>>> engineers = Set(['John', 'Jane', 'Jack', 'Janice'])
>>> programmers = Set(['Jack', 'Sam', 'Susan', 'Janice'])
>>> management = Set(['Jane', 'Jack', 'Susan', 'Zack'])
@@ -650,7 +653,7 @@ Example from the Library Reference: Doc/lib/libsets.tex
>>> fulltime_management = management - engineers - programmers # difference
>>> engineers.add('Marvin')
>>> print engineers
-Set(['Jane', 'Marvin', 'Janice', 'John', 'Jack'])
+Set(['Jack', 'Jane', 'Janice', 'John', 'Marvin'])
>>> employees.issuperset(engineers) # superset test
False
>>> employees.update(engineers) # update from another set
@@ -660,10 +663,10 @@ True
... group.discard('Susan') # unconditionally remove element
... print group
...
-Set(['Jane', 'Marvin', 'Janice', 'John', 'Jack'])
-Set(['Janice', 'Jack', 'Sam'])
-Set(['Jane', 'Zack', 'Jack'])
-Set(['Zack', 'Sam', 'Marvin', 'Jack', 'Jane', 'Janice', 'John'])
+Set(['Jack', 'Jane', 'Janice', 'John', 'Marvin'])
+Set(['Jack', 'Janice', 'Sam'])
+Set(['Jack', 'Jane', 'Zack'])
+Set(['Jack', 'Jane', 'Janice', 'John', 'Marvin', 'Sam', 'Zack'])
"""
#==============================================================================