From 32f41536cbcae7ebcec748a66165b210cfe88fd7 Mon Sep 17 00:00:00 2001 From: Neal Norwitz Date: Sat, 29 Dec 2001 00:35:20 +0000 Subject: SF Patch #494874 add tests for int()/long() invalid parameters --- Lib/test/test_b1.py | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/Lib/test/test_b1.py b/Lib/test/test_b1.py index f2d0c24..17f0411 100644 --- a/Lib/test/test_b1.py +++ b/Lib/test/test_b1.py @@ -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\')' -- cgit v0.12