[Python-checkins] python/dist/src/Lib/test test_sets.py,1.19,1.20

tim_one@users.sourceforge.net tim_one@users.sourceforge.net
Sat, 01 Mar 2003 15:33:36 -0800


Update of /cvsroot/python/python/dist/src/Lib/test
In directory sc8-pr-cvs1:/tmp/cvs-serv11029/Lib/test

Modified Files:
	test_sets.py 
Log Message:
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).


Index: test_sets.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/test/test_sets.py,v
retrieving revision 1.19
retrieving revision 1.20
diff -C2 -d -r1.19 -r1.20
*** test_sets.py	15 Jan 2003 16:15:38 -0000	1.19
--- test_sets.py	1 Mar 2003 23:33:34 -0000	1.20
***************
*** 642,646 ****
  Example from the Library Reference:  Doc/lib/libsets.tex
  
! >>> from sets import Set
  >>> engineers = Set(['John', 'Jane', 'Jack', 'Janice'])
  >>> programmers = Set(['Jack', 'Sam', 'Susan', 'Janice'])
--- 642,649 ----
  Example from the Library Reference:  Doc/lib/libsets.tex
  
! >>> 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'])
***************
*** 651,655 ****
  >>> engineers.add('Marvin')
  >>> print engineers
! Set(['Jane', 'Marvin', 'Janice', 'John', 'Jack'])
  >>> employees.issuperset(engineers)           # superset test
  False
--- 654,658 ----
  >>> engineers.add('Marvin')
  >>> print engineers
! Set(['Jack', 'Jane', 'Janice', 'John', 'Marvin'])
  >>> employees.issuperset(engineers)           # superset test
  False
***************
*** 661,668 ****
  ...     print group
  ...
! Set(['Jane', 'Marvin', 'Janice', 'John', 'Jack'])
! Set(['Janice', 'Jack', 'Sam'])
! Set(['Jane', 'Zack', 'Jack'])
! Set(['Zack', 'Sam', 'Marvin', 'Jack', 'Jane', 'Janice', 'John'])
  """
  
--- 664,671 ----
  ...     print group
  ...
! Set(['Jack', 'Jane', 'Janice', 'John', 'Marvin'])
! Set(['Jack', 'Janice', 'Sam'])
! Set(['Jack', 'Jane', 'Zack'])
! Set(['Jack', 'Jane', 'Janice', 'John', 'Marvin', 'Sam', 'Zack'])
  """