diff options
author | Neal Norwitz <nnorwitz@gmail.com> | 2005-11-27 20:37:43 (GMT) |
---|---|---|
committer | Neal Norwitz <nnorwitz@gmail.com> | 2005-11-27 20:37:43 (GMT) |
commit | fcf4435ae02c3962a8ad71a9539877060c694468 (patch) | |
tree | 66b05ecac0df3d4105c15ee62f6ea8b520e87312 /Lib/test/test_builtin.py | |
parent | 307021f40b227d2bf114b536c37cc41e03fc2aff (diff) | |
download | cpython-fcf4435ae02c3962a8ad71a9539877060c694468.zip cpython-fcf4435ae02c3962a8ad71a9539877060c694468.tar.gz cpython-fcf4435ae02c3962a8ad71a9539877060c694468.tar.bz2 |
Improve test coverage. Hope the test_file changes work the same on windows.
Diffstat (limited to 'Lib/test/test_builtin.py')
-rw-r--r-- | Lib/test/test_builtin.py | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/Lib/test/test_builtin.py b/Lib/test/test_builtin.py index d3eb2af..dd00874 100644 --- a/Lib/test/test_builtin.py +++ b/Lib/test/test_builtin.py @@ -238,8 +238,11 @@ class BuiltinTest(unittest.TestCase): 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') 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 @@ -421,6 +424,7 @@ class BuiltinTest(unittest.TestCase): unlink(TESTFN) self.assertRaises(TypeError, execfile) + self.assertRaises(TypeError, execfile, TESTFN, {}, ()) import os self.assertRaises(IOError, execfile, os.curdir) self.assertRaises(IOError, execfile, "I_dont_exist") @@ -1008,6 +1012,9 @@ class BuiltinTest(unittest.TestCase): def __getitem__(self, index): raise ValueError self.assertRaises(ValueError, map, lambda x: x, BadSeq()) + def badfunc(x): + raise RuntimeError + self.assertRaises(RuntimeError, map, badfunc, range(5)) def test_max(self): self.assertEqual(max('123123'), '3') @@ -1239,6 +1246,12 @@ class BuiltinTest(unittest.TestCase): self.assertRaises(TypeError, range) self.assertRaises(TypeError, range, 1, 2, 3, 4) self.assertRaises(ValueError, range, 1, 2, 0) + self.assertRaises(ValueError, range, a, a + 1, long(0)) + + class badzero(int): + def __cmp__(self, other): + raise RuntimeError + self.assertRaises(RuntimeError, range, a, a + 1, badzero(1)) # Reject floats when it would require PyLongs to represent. # (smaller floats still accepted, but deprecated) |