[Python-checkins] python/dist/src/Lib/test test_decimal.py, 1.11, 1.12

rhettinger at users.sourceforge.net rhettinger at users.sourceforge.net
Tue Aug 17 07:42:17 CEST 2004


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

Modified Files:
	test_decimal.py 
Log Message:
* Dynamically build a list of files to be tested (necessary because
  version 2.39 of dectest.zip adds some new test files and because
  some existing test files were getting skipped).
* Remove two docstrings which cluttered unittest's output.
* Simplify a for-loop with a list comprehension.



Index: test_decimal.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/test/test_decimal.py,v
retrieving revision 1.11
retrieving revision 1.12
diff -C2 -d -r1.11 -r1.12
*** test_decimal.py	8 Aug 2004 20:17:45 -0000	1.11
--- test_decimal.py	17 Aug 2004 05:42:09 -0000	1.12
***************
*** 280,288 ****
  
      def getexceptions(self):
!         L = []
!         for exception in Signals:
!             if self.context.flags[exception]:
!                 L.append(exception)
!         return L
  
      def change_precision(self, prec):
--- 280,284 ----
  
      def getexceptions(self):
!         return [e for e in Signals if self.context.flags[e]]
  
      def change_precision(self, prec):
***************
*** 297,379 ****
          self.context._clamp = clamp
  
!     def test_abs(self):
!         self.eval_file(dir + 'abs' + '.decTest')
! 
!     def test_add(self):
!         self.eval_file(dir + 'add' + '.decTest')
! 
!     def test_base(self):
!         self.eval_file(dir + 'base' + '.decTest')
! 
!     def test_clamp(self):
!         self.eval_file(dir + 'clamp' + '.decTest')
! 
!     def test_compare(self):
!         self.eval_file(dir + 'compare' + '.decTest')
! 
!     def test_divide(self):
!         self.eval_file(dir + 'divide' + '.decTest')
! 
!     def test_divideint(self):
!         self.eval_file(dir + 'divideint' + '.decTest')
! 
!     def test_inexact(self):
!         self.eval_file(dir + 'inexact' + '.decTest')
! 
!     def test_max(self):
!         self.eval_file(dir + 'max' + '.decTest')
! 
!     def test_min(self):
!         self.eval_file(dir + 'min' + '.decTest')
! 
!     def test_minus(self):
!         self.eval_file(dir + 'minus' + '.decTest')
! 
!     def test_multiply(self):
!         self.eval_file(dir+'multiply'+'.decTest')
! 
!     def test_normalize(self):
!         self.eval_file(dir + 'normalize' + '.decTest')
! 
!     def test_plus(self):
!         self.eval_file(dir + 'plus' + '.decTest')
! 
!     def test_power(self):
!         self.eval_file(dir + 'power' + '.decTest')
! 
!     def test_quantize(self):
!         self.eval_file(dir + 'quantize' + '.decTest')
! 
!     def test_randomBound32(self):
!         self.eval_file(dir + 'randomBound32' + '.decTest')
! 
!     def test_randoms(self):
!         self.eval_file(dir + 'randoms' + '.decTest')
! 
!     def test_remainder(self):
!         self.eval_file(dir + 'remainder' + '.decTest')
! 
!     def test_remainderNear(self):
!         self.eval_file(dir + 'remainderNear' + '.decTest')
! 
!     def test_rounding(self):
!         self.eval_file(dir + 'rounding' + '.decTest')
! 
!     def test_samequantum(self):
!         self.eval_file(dir + 'samequantum' + '.decTest')
! 
!     def test_squareroot(self):
!         self.eval_file(dir + 'squareroot' + '.decTest')
! 
!     def test_subtract(self):
!         self.eval_file(dir + 'subtract' + '.decTest')
  
-     def test_tointegral(self):
-         self.eval_file(dir + 'tointegral' + '.decTest')
  
  
  # The following classes test the behaviour of Decimal according to PEP 327
  
- 
  class DecimalExplicitConstructionTest(unittest.TestCase):
      '''Unit tests for Explicit Construction cases of Decimal.'''
--- 293,314 ----
          self.context._clamp = clamp
  
! # Dynamically build custom test definition for each file in the test
! # directory and add the definitions to the DecimalTest class.  This
! # procedure insures that new files do not get skipped.
! for filename in os.listdir(dir):
!     if '.decTest' not in filename:
!         continue
!     ## XXX buildout to include integer and trim
!     if 'integer' in filename or 'trim' in filename:
!         continue
!     head, tail = filename.split('.')
!     tester = lambda self, f=filename: self.eval_file(dir + f)
!     setattr(DecimalTest, 'test_' + head, tester)
!     del filename, head, tail, tester
  
  
  
  # The following classes test the behaviour of Decimal according to PEP 327
  
  class DecimalExplicitConstructionTest(unittest.TestCase):
      '''Unit tests for Explicit Construction cases of Decimal.'''
***************
*** 404,408 ****
  
      def test_explicit_from_string(self):
-         '''Explicit construction with string.'''
  
          #empty
--- 339,342 ----
***************
*** 816,820 ****
  
      def test_comparison_operators(self):
-         '''Testing ==, !=, <, >, <=, >=, cmp.'''
  
          da = Decimal('23.42')
--- 750,753 ----



More information about the Python-checkins mailing list