home *** CD-ROM | disk | FTP | other *** search
/ The Datafile PD-CD 5 / DATAFILE_PDCD5.iso / utilities / p / python / !Python / test / py / test_strop < prev    next >
Encoding:
Text File  |  1996-11-06  |  480 b   |  21 lines

  1. import strop, sys
  2.  
  3. def test(name, input, output):
  4.     f = getattr(strop, name)
  5.     try:
  6.     value = f(input)
  7.     except:
  8.      value = sys.exc_type
  9.     if value != output:
  10.     print f, `input`, `output`, `value`
  11.  
  12. test('atoi', " 1 ", 1)
  13. test('atoi', " 1x", ValueError)
  14. test('atoi', " x1 ", ValueError)
  15. test('atol', "  1  ", 1L)
  16. test('atol', "  1x ", ValueError)
  17. test('atol', "  x1 ", ValueError)
  18. test('atof', "  1  ", 1.0)
  19. test('atof', "  1x ", ValueError)
  20. test('atof', "  x1 ", ValueError)
  21.