mirror of
https://github.com/python/cpython.git
synced 2025-11-01 10:45:30 +00:00
SF Patch #494874 add tests for int()/long() invalid parameters
This commit is contained in:
parent
707690132f
commit
32f41536cb
1 changed files with 23 additions and 0 deletions
|
|
@ -432,6 +432,21 @@ try: int('123\0')
|
|||
except ValueError: pass
|
||||
else: raise TestFailed("int('123\0') didn't raise exception")
|
||||
|
||||
try: int('53', 40)
|
||||
except ValueError: pass
|
||||
else: raise TestFailed("int('53', 40) didn't raise ValueError")
|
||||
|
||||
try: int('1' * 512)
|
||||
except ValueError: pass
|
||||
else: raise TestFailed("int('1' * 512) didn't raise ValueError")
|
||||
|
||||
try: int(1, 12)
|
||||
except TypeError: pass
|
||||
else: raise TestFailed("int(1, 12) didn't raise TypeError")
|
||||
|
||||
if int('0123', 0) != 83:
|
||||
raise TestFailed("int('0123', 0) != 83")
|
||||
|
||||
print 'isinstance'
|
||||
class C:
|
||||
pass
|
||||
|
|
@ -524,6 +539,14 @@ try: long('123\0')
|
|||
except ValueError: pass
|
||||
else: raise TestFailed("long('123\0') didn't raise exception")
|
||||
|
||||
try: long('53', 40)
|
||||
except ValueError: pass
|
||||
else: raise TestFailed("long('53', 40) didn't raise ValueError")
|
||||
|
||||
try: long(1, 12)
|
||||
except TypeError: pass
|
||||
else: raise TestFailed("long(1, 12) didn't raise TypeError")
|
||||
|
||||
print 'map'
|
||||
if map(None, 'hello world') != ['h','e','l','l','o',' ','w','o','r','l','d']:
|
||||
raise TestFailed, 'map(None, \'hello world\')'
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue