Staging
v0.8.1
https://github.com/python/cpython
Raw File
Tip revision: 6c3a3aa17b028f6b93067083d32c7eaa4338757c authored by cvs2svn on 25 October 1996, 15:40:20 UTC
This commit was manufactured by cvs2svn to create tag 'release14'.
Tip revision: 6c3a3aa
test_strop.py
import strop, sys

def test(name, input, output):
    f = getattr(strop, name)
    try:
	value = f(input)
    except:
	 value = sys.exc_type
    if value != output:
	print f, `input`, `output`, `value`

test('atoi', " 1 ", 1)
test('atoi', " 1x", ValueError)
test('atoi', " x1 ", ValueError)
test('atol', "  1  ", 1L)
test('atol', "  1x ", ValueError)
test('atol', "  x1 ", ValueError)
test('atof', "  1  ", 1.0)
test('atof', "  1x ", ValueError)
test('atof', "  x1 ", ValueError)
back to top