diff options
Diffstat (limited to 'Lib/test/test_builtin.py')
-rw-r--r-- | Lib/test/test_builtin.py | 18 |
1 files changed, 16 insertions, 2 deletions
diff --git a/Lib/test/test_builtin.py b/Lib/test/test_builtin.py index 500516c..ffa74af 100644 --- a/Lib/test/test_builtin.py +++ b/Lib/test/test_builtin.py @@ -107,9 +107,12 @@ class BuiltinTest(unittest.TestCase): __import__('sys') __import__('time') __import__('string') + __import__(name='sys') + __import__(name='time', level=0) self.assertRaises(ImportError, __import__, 'spamspam') self.assertRaises(TypeError, __import__, 1, 2, 3, 4) self.assertRaises(ValueError, __import__, '') + self.assertRaises(TypeError, __import__, 'sys', name='sys') def test_abs(self): # int @@ -207,15 +210,21 @@ class BuiltinTest(unittest.TestCase): compile('print(1)\n', '', 'exec') bom = '\xef\xbb\xbf' compile(bom + 'print(1)\n', '', 'exec') + compile(source='pass', filename='?', mode='exec') + compile(dont_inherit=0, filename='tmp', source='0', mode='eval') + compile('pass', '?', dont_inherit=1, mode='exec') self.assertRaises(TypeError, compile) self.assertRaises(ValueError, compile, 'print(42)\n', '<string>', 'badmode') self.assertRaises(ValueError, compile, 'print(42)\n', '<string>', 'single', 0xff) self.assertRaises(TypeError, compile, chr(0), 'f', 'exec') + self.assertRaises(TypeError, compile, 'pass', '?', 'exec', + mode='eval', source='0', filename='tmp') if have_unicode: compile(unicode('print(u"\xc3\xa5")\n', 'utf8'), '', 'exec') self.assertRaises(TypeError, compile, unichr(0), 'f', 'exec') self.assertRaises(ValueError, compile, unicode('a = 1'), 'f', 'bad') + def test_delattr(self): import sys sys.spam = 1 @@ -1035,6 +1044,11 @@ class BuiltinTest(unittest.TestCase): self.assertRaises(ValueError, int, '53', 40) self.assertRaises(TypeError, int, 1, 12) + # SF patch #1638879: embedded NULs were not detected with + # explicit base + self.assertRaises(ValueError, int, '123\0', 10) + self.assertRaises(ValueError, int, '123\x00 245', 20) + self.assertEqual(int('100000000000000000000000000000000', 2), 4294967296) self.assertEqual(int('102002022201221111211', 3), 4294967296) @@ -1138,10 +1152,10 @@ class BuiltinTest(unittest.TestCase): self.assertEqual(int(Foo0()), 42) self.assertEqual(int(Foo1()), 42) - # XXX invokes __int__ now + # XXX invokes __int__ now # self.assertEqual(long(Foo2()), 42L) self.assertEqual(int(Foo3()), 0) - # XXX likewise + # XXX likewise # self.assertEqual(long(Foo4()), 42) # self.assertRaises(TypeError, long, Foo5()) |