[Python-checkins] python/dist/src/Lib/test test_decimal.py,1.4,1.5

rhettinger at users.sourceforge.net rhettinger at users.sourceforge.net
Tue Jul 6 00:53:06 CEST 2004


Update of /cvsroot/python/python/dist/src/Lib/test
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv24143/test

Modified Files:
	test_decimal.py 
Log Message:
* Add __eq__ and __ne__ so that things like list.index() work properly 
  for lists of mixed types.
* Test that sort works.



Index: test_decimal.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/test/test_decimal.py,v
retrieving revision 1.4
retrieving revision 1.5
diff -C2 -d -r1.4 -r1.5
*** test_decimal.py	5 Jul 2004 18:49:38 -0000	1.4
--- test_decimal.py	5 Jul 2004 22:53:03 -0000	1.5
***************
*** 34,37 ****
--- 34,38 ----
  from test.test_support import TestSkipped, run_unittest, run_doctest, is_resource_enabled
  import threading
+ import random
  
  # Tests are built around these assumed context defaults
***************
*** 842,856 ****
  
          #a Decimal and uncomparable
!         try: da == 'ugly'
!         except TypeError: pass
!         else: self.fail('Did not raised an error!')
! 
!         try: da == '32.7'
!         except TypeError: pass
!         else: self.fail('Did not raised an error!')
  
!         try: da == object
!         except TypeError: pass
!         else: self.fail('Did not raised an error!')
  
      def test_copy_and_deepcopy_methods(self):
--- 843,857 ----
  
          #a Decimal and uncomparable
!         self.assertNotEqual(da, 'ugly')
!         self.assertNotEqual(da, 32.7)
!         self.assertNotEqual(da, object())
!         self.assertNotEqual(da, object)
  
!         # sortable
!         a = map(Decimal, xrange(100))
!         b =  a[:]
!         random.shuffle(a)
!         a.sort()
!         self.assertEqual(a, b)
  
      def test_copy_and_deepcopy_methods(self):
***************
*** 1079,1082 ****
--- 1080,1087 ----
              self.assertEqual(v1, v2)
  
+     def test_equality_with_other_types(self):
+         self.assert_(Decimal(10) in ['a', 1.0, Decimal(10), (1,2), {}])
+         self.assert_(Decimal(10) not in ['a', 1.0, (1,2), {}])
+ 
  def test_main(arith=False, verbose=None):
      """ Execute the tests.



More information about the Python-checkins mailing list