[Patches] fix test_math.py crash on Win32 (no math.rint())

Trent Mick trentm@activestate.com
Thu, 1 Jun 2000 02:20:33 -0700


Discussion:

With the (relatively recent) platform-conditional addition of math.rint to the
math module, the associate test in test_math causes 'test_math' to crash on
platforms without rint (i.e. Win32). THis patch makes test_math.py tolerant of
a platform not having rint.

Legal:

I confirm that, to the best of my knowledge and belief, this
contribution is free of any claims of third parties under
copyright, patent or other rights or interests ("claims").  To
the extent that I have any such claims, I hereby grant to CNRI a
nonexclusive, irrevocable, royalty-free, worldwide license to
reproduce, distribute, perform and/or display publicly, prepare
derivative versions, and otherwise use this contribution as part
of the Python software and its related documentation, or any
derivative versions thereof, at no cost to CNRI or its licensed
users, and to authorize others to do so.

I acknowledge that CNRI may, at its sole discretion, decide
whether or not to incorporate this contribution in the Python
software and its related documentation.  I further grant CNRI
permission to use my name and other identifying information
provided to CNRI by me for use in connection with the Python
software and its related documentation.


Patch (use 'patch -p8'):

*** /home/trentm/main/contrib/python/dist/src/Lib/test/test_math.py	Thu Jun  1 00:13:38 2000
--- /home/trentm/main/Apps/Perlium/Python/dist/src/Lib/test/test_math.py	Wed May 31 23:54:16 2000
***************
*** 130,139 ****
  testit('pow(2,-1)', math.pow(2,-1), 0.5)
  
  print 'rint'
! testit('rint(0.7)', math.rint(0.7), 1)
! testit('rint(-0.3)', math.rint(-0.3), 0)
! testit('rint(2.5)', math.rint(2.5), 2)
! testit('rint(3.5)', math.rint(3.5), 4) 
  
  print 'sin'
  testit('sin(0)', math.sin(0), 0)
--- 130,143 ----
  testit('pow(2,-1)', math.pow(2,-1), 0.5)
  
  print 'rint'
! try:
! 	testit('rint(0.7)', math.rint(0.7), 1)
! 	testit('rint(-0.3)', math.rint(-0.3), 0)
! 	testit('rint(2.5)', math.rint(2.5), 2)
! 	testit('rint(3.5)', math.rint(3.5), 4) 
! except AttributeError:
! 	# this platform does not have rint, that is fine, skip the test
! 	pass
  
  print 'sin'
  testit('sin(0)', math.sin(0), 0)

-- 
Trent Mick
trentm@activestate.com