Commit 3ba491e6 authored by Tim Peters's avatar Tim Peters

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).
parent f421e81e
...@@ -641,7 +641,10 @@ class TestCopyingNested(TestCopying): ...@@ -641,7 +641,10 @@ class TestCopyingNested(TestCopying):
libreftest = """ libreftest = """
Example from the Library Reference: Doc/lib/libsets.tex 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']) >>> engineers = Set(['John', 'Jane', 'Jack', 'Janice'])
>>> programmers = Set(['Jack', 'Sam', 'Susan', 'Janice']) >>> programmers = Set(['Jack', 'Sam', 'Susan', 'Janice'])
>>> management = Set(['Jane', 'Jack', 'Susan', 'Zack']) >>> management = Set(['Jane', 'Jack', 'Susan', 'Zack'])
...@@ -650,7 +653,7 @@ Example from the Library Reference: Doc/lib/libsets.tex ...@@ -650,7 +653,7 @@ Example from the Library Reference: Doc/lib/libsets.tex
>>> fulltime_management = management - engineers - programmers # difference >>> fulltime_management = management - engineers - programmers # difference
>>> engineers.add('Marvin') >>> engineers.add('Marvin')
>>> print engineers >>> print engineers
Set(['Jane', 'Marvin', 'Janice', 'John', 'Jack']) Set(['Jack', 'Jane', 'Janice', 'John', 'Marvin'])
>>> employees.issuperset(engineers) # superset test >>> employees.issuperset(engineers) # superset test
False False
>>> employees.update(engineers) # update from another set >>> employees.update(engineers) # update from another set
...@@ -660,10 +663,10 @@ True ...@@ -660,10 +663,10 @@ True
... group.discard('Susan') # unconditionally remove element ... group.discard('Susan') # unconditionally remove element
... print group ... print group
... ...
Set(['Jane', 'Marvin', 'Janice', 'John', 'Jack']) Set(['Jack', 'Jane', 'Janice', 'John', 'Marvin'])
Set(['Janice', 'Jack', 'Sam']) Set(['Jack', 'Janice', 'Sam'])
Set(['Jane', 'Zack', 'Jack']) Set(['Jack', 'Jane', 'Zack'])
Set(['Zack', 'Sam', 'Marvin', 'Jack', 'Jane', 'Janice', 'John']) Set(['Jack', 'Jane', 'Janice', 'John', 'Marvin', 'Sam', 'Zack'])
""" """
#============================================================================== #==============================================================================
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment