mirror of
https://github.com/python/cpython.git
synced 2025-08-04 08:59:19 +00:00
Simple test module for strop.
This commit is contained in:
parent
3159e1e1ef
commit
edaf1c931c
1 changed files with 21 additions and 0 deletions
21
Lib/test/test_strop.py
Normal file
21
Lib/test/test_strop.py
Normal file
|
@ -0,0 +1,21 @@
|
|||
import strop, sys
|
||||
|
||||
def test(name, input, output):
|
||||
f = getattr(strop, name)
|
||||
try:
|
||||
value = f(input)
|
||||
except:
|
||||
value = sys.exc_type
|
||||
print sys.exc_value
|
||||
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)
|
Loading…
Add table
Add a link
Reference in a new issue