[Python-checkins] python/nondist/sandbox/decimal test_Decimal.py,1.1,1.2

eprice@users.sourceforge.net eprice@users.sourceforge.net
2003年7月02日 16:50:03 -0700


Update of /cvsroot/python/python/nondist/sandbox/decimal
In directory sc8-pr-cvs1:/tmp/cvs-serv994
Modified Files:
	test_Decimal.py 
Log Message:
Changed rescale test cases to the new quantize one.
Moved in a list that had been in the main class.
Index: test_Decimal.py
===================================================================
RCS file: /cvsroot/python/python/nondist/sandbox/decimal/test_Decimal.py,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** test_Decimal.py	21 May 2003 16:20:24 -0000	1.1
--- test_Decimal.py	2 Jul 2003 23:50:01 -0000	1.2
***************
*** 12,15 ****
--- 12,35 ----
 skip_expected = not os.path.isdir(dir)
 
+ 
+ #Map the test cases' error names to the actual errors
+ 
+ ErrorNames = {'clamped' : Clamped,
+ 'conversion_syntax' : ConversionSyntax,
+ 'division_by_zero' : DivisionByZero,
+ 'division_impossible' : DivisionImpossible,
+ 'division_undefined' : DivisionUndefined,
+ 'inexact' : Inexact,
+ 'insufficient_storage' : InsufficientStorage,
+ 'invalid_context' : InvalidContext,
+ 'invalid_operation' : InvalidOperation,
+ 'lost_digits' : LostDigits,
+ 'overflow' : Overflow,
+ 'rounded' : Rounded,
+ 'subnormal' : Subnormal,
+ 'underflow' : Underflow}
+ 
+ 
+ 
 def Nonfunction(*args):
 """Doesn't do anything."""
***************
*** 102,106 ****
 id = L[0]
 #print id,
! funct = L[1]
 valstemp = L[2:]
 L = Sides[1].strip().split()
--- 122,126 ----
 id = L[0]
 #print id,
! funct = L[1].lower()
 valstemp = L[2:]
 L = Sides[1].strip().split()
***************
*** 116,119 ****
--- 136,141 ----
 fname = funct
 funct = getattr(self.context, funct)
+ if fname == 'rescale':
+ return 
 vals = []
 conglomerate = ''
***************
*** 125,129 ****
 for exception in theirexceptions:
 self.context.trap_enablers[exception] = 0
! for val in valstemp:
 if val.count("'") % 2 == 1:
 quote = 1 - quote
--- 147,151 ----
 for exception in theirexceptions:
 self.context.trap_enablers[exception] = 0
! for i, val in enumerate(valstemp):
 if val.count("'") % 2 == 1:
 quote = 1 - quote
***************
*** 135,140 ****
 conglomerate = ''
 v = FixQuotes(val)
! if fname in ('toSci', 'toEng'):
 v = self.context.new(v)
 else:
 v = Decimal(v)
--- 157,167 ----
 conglomerate = ''
 v = FixQuotes(val)
! if fname in ('tosci', 'toeng'):
 v = self.context.new(v)
+ #elif fname == 'rescale' and i == 1:
+ # try:
+ # v = int(Decimal(v))
+ # except ValueError:
+ # v = float(v)
 else:
 v = Decimal(v)
***************
*** 145,150 ****
 try:
 result = str(funct(*vals))
 except: #Catch any error long enough to state the test case.
! #print "ERROR:", s
 raise
 
--- 172,179 ----
 try:
 result = str(funct(*vals))
+ except ExceptionList, error:
+ self.fail("Raised %s in %s" % (error, s))
 except: #Catch any error long enough to state the test case.
! print "ERROR:", s
 raise
 
***************
*** 295,298 ****
--- 324,334 ----
 self.eval_file(dir + 'power' + '.decTest')
 
+ def test_quantize(self):
+ """Tests the Decimal class on Cowlishaw's quantize tests.
+ 
+ See www2.hursley.ibm.com/decimal/decTest.zip to download the suite.
+ """
+ self.eval_file(dir + 'quantize' + '.decTest')
+ 
 def test_randomBound32(self):
 """Tests the Decimal class on Cowlishaw's randomBound32 tests.
***************
*** 322,332 ****
 """
 self.eval_file(dir + 'remainderNear' + '.decTest')
- 
- def test_rescale(self):
- """Tests the Decimal class on Cowlishaw's rescale tests.
- 
- See www2.hursley.ibm.com/decimal/decTest.zip to download the suite.
- """
- self.eval_file(dir + 'rescale' + '.decTest')
 
 def test_rounding(self):
--- 358,361 ----

AltStyle によって変換されたページ (->オリジナル) /