[Python-checkins] CVS: python/dist/src/Lib/test test_compare.py,1.1,1.2

Neil Schemenauer python-dev@python.org
Tue, 02 Jan 2001 18:13:28 -0800


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

Modified Files:
	test_compare.py 
Log Message:
Use == rather than cmp().  The return value of cmp() is not well defined when
comparing different types.


Index: test_compare.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/test/test_compare.py,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -r1.1 -r1.2
*** test_compare.py	2001/01/02 16:30:31	1.1
--- test_compare.py	2001/01/03 02:13:26	1.2
***************
*** 18,22 ****
              return self.arg, other.arg
          else:
!             return (self.arg, other)
  
  class Cmp:
--- 18,22 ----
              return self.arg, other.arg
          else:
!             return self.arg, other
  
  class Cmp:
***************
*** 41,57 ****
   
  
! candidates = [2, 2.2, 2L, 2+4j, [1], (2,), None, Empty(), Coerce(3),
!                 Cmp(4), RCmp(5)]
  
  def test():
      for a in candidates:
          for b in candidates:
-             print "cmp(%s, %s)" % (a, b),
              try:
!                 x = cmp(a, b)
              except:
!                 print '... %s' % sys.exc_info(0)
              else:
!                 print '=', x
  
  test()
--- 41,59 ----
   
  
! candidates = [2, 2.0, 2L, 2+0j, [1], (3,), None, Empty(), Coerce(2),
!                 Cmp(2.0), RCmp(2L)]
  
  def test():
      for a in candidates:
          for b in candidates:
              try:
!                 x = a == b
              except:
!                 print 'cmp(%s, %s) => %s' % (a, b, sys.exc_info()[0])
              else:
!                 if x:
!                     print "%s == %s" % (a, b)
!                 else:
!                     print "%s != %s" % (a, b)
  
  test()