[Python-checkins] python/dist/src/Lib/test test_decimal.py,1.7,1.8

rhettinger at users.sourceforge.net rhettinger at users.sourceforge.net
Sat Jul 10 16:14:40 CEST 2004


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

Modified Files:
	test_decimal.py 
Log Message:
Improve Context construction and representation:

* Rename "trap_enablers" to just "traps".
* Simplify names of "settraps" and "setflags" to just "traps" and "flags".
* Show "capitals" in the context representation
* Simplify the Context constructor to match its repr form so that only
  the set flags and traps need to be listed.
* Representation can now be run through eval().

Improve the error message when the Decimal constructor is given a float.

The test suite no longer needs a duplicate reset_flags method.



Index: test_decimal.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/test/test_decimal.py,v
retrieving revision 1.7
retrieving revision 1.8
diff -C2 -d -r1.7 -r1.8
*** test_decimal.py	9 Jul 2004 10:52:54 -0000	1.7
--- test_decimal.py	10 Jul 2004 14:14:37 -0000	1.8
***************
*** 39,43 ****
  DefaultContext.prec=9
  DefaultContext.rounding=ROUND_HALF_EVEN
! DefaultContext.trap_enablers=dict.fromkeys(Signals, 0)
  setcontext(DefaultContext)
  
--- 39,43 ----
  DefaultContext.prec=9
  DefaultContext.rounding=ROUND_HALF_EVEN
! DefaultContext.traps=dict.fromkeys(Signals, 0)
  setcontext(DefaultContext)
  
***************
*** 106,111 ****
          global dir
          self.context = Context()
!         for key in DefaultContext.trap_enablers.keys():
!             DefaultContext.trap_enablers[key] = 1
          self.ignore_list = ['#']
          # Basically, a # means return NaN InvalidOperation.
--- 106,111 ----
          global dir
          self.context = Context()
!         for key in DefaultContext.traps.keys():
!             DefaultContext.traps[key] = 1
          self.ignore_list = ['#']
          # Basically, a # means return NaN InvalidOperation.
***************
*** 121,126 ****
          """Cleaning up enviroment."""
          # leaving context in original state
!         for key in DefaultContext.trap_enablers.keys():
!             DefaultContext.trap_enablers[key] = 0
          return
  
--- 121,126 ----
          """Cleaning up enviroment."""
          # leaving context in original state
!         for key in DefaultContext.traps.keys():
!             DefaultContext.traps[key] = 0
          return
  
***************
*** 206,212 ****
  
          for exception in Signals:
!             self.context.trap_enablers[exception] = 1 #Catch these bugs...
          for exception in theirexceptions:
!             self.context.trap_enablers[exception] = 0
          for i, val in enumerate(valstemp):
              if val.count("'") % 2 == 1:
--- 206,212 ----
  
          for exception in Signals:
!             self.context.traps[exception] = 1 #Catch these bugs...
          for exception in theirexceptions:
!             self.context.traps[exception] = 0
          for i, val in enumerate(valstemp):
              if val.count("'") % 2 == 1:
***************
*** 222,226 ****
                  if EXTENDEDERRORTEST:
                      for error in theirexceptions:
!                         self.context.trap_enablers[error] = 1
                          try:
                              funct(self.context.create_decimal(v))
--- 222,226 ----
                  if EXTENDEDERRORTEST:
                      for error in theirexceptions:
!                         self.context.traps[error] = 1
                          try:
                              funct(self.context.create_decimal(v))
***************
*** 232,236 ****
                          else:
                              self.fail("Did not raise %s in %s" % (error, s))
!                         self.context.trap_enablers[error] = 0
                  v = self.context.create_decimal(v)
              else:
--- 232,236 ----
                          else:
                              self.fail("Did not raise %s in %s" % (error, s))
!                         self.context.traps[error] = 0
                  v = self.context.create_decimal(v)
              else:
***************
*** 242,246 ****
          if EXTENDEDERRORTEST and fname not in ('to_sci_string', 'to_eng_string'):
              for error in theirexceptions:
!                 self.context.trap_enablers[error] = 1
                  try:
                      funct(*vals)
--- 242,246 ----
          if EXTENDEDERRORTEST and fname not in ('to_sci_string', 'to_eng_string'):
              for error in theirexceptions:
!                 self.context.traps[error] = 1
                  try:
                      funct(*vals)
***************
*** 252,256 ****
                  else:
                      self.fail("Did not raise %s in %s" % (error, s))
!                 self.context.trap_enablers[error] = 0
          try:
              result = str(funct(*vals))
--- 252,256 ----
                  else:
                      self.fail("Did not raise %s in %s" % (error, s))
!                 self.context.traps[error] = 0
          try:
              result = str(funct(*vals))
***************
*** 264,268 ****
  
          myexceptions = self.getexceptions()
!         self.resetflags()
  
          myexceptions.sort()
--- 264,268 ----
  
          myexceptions = self.getexceptions()
!         self.context.clear_flags()
  
          myexceptions.sort()
***************
*** 283,290 ****
          return L
  
-     def resetflags(self):
-         for exception in Signals:
-             self.context.flags[exception] = 0
- 
      def change_precision(self, prec):
          self.context.prec = prec
--- 283,286 ----



More information about the Python-checkins mailing list