diff options
author | Guido van Rossum <guido@python.org> | 2007-05-17 18:20:34 (GMT) |
---|---|---|
committer | Guido van Rossum <guido@python.org> | 2007-05-17 18:20:34 (GMT) |
commit | ebe3e16600ddbc19aa7444ec773e2e0786b8a3cf (patch) | |
tree | 1189de0bc8de926ef5b1baa2f646cbd1674b8bab /Lib/test/test_exceptions.py | |
parent | e35553e24c6b90db9ab22298cef663192972bbab (diff) | |
download | cpython-ebe3e16600ddbc19aa7444ec773e2e0786b8a3cf.zip cpython-ebe3e16600ddbc19aa7444ec773e2e0786b8a3cf.tar.gz cpython-ebe3e16600ddbc19aa7444ec773e2e0786b8a3cf.tar.bz2 |
Merged revisions 55342-55406 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/branches/p3yk
........
r55360 | guido.van.rossum | 2007-05-15 14:57:59 -0700 (Tue, 15 May 2007) | 2 lines
obcheckin.
........
r55361 | guido.van.rossum | 2007-05-15 14:59:18 -0700 (Tue, 15 May 2007) | 2 lines
Get rid of strop module.
........
r55367 | brett.cannon | 2007-05-15 21:06:28 -0700 (Tue, 15 May 2007) | 2 lines
Remove the 'pure' module.
........
r55369 | brett.cannon | 2007-05-15 21:07:31 -0700 (Tue, 15 May 2007) | 2 lines
Remove the lib-old directory (already empty).
........
r55370 | neal.norwitz | 2007-05-15 21:30:40 -0700 (Tue, 15 May 2007) | 1 line
Get rid of a bunch more references to strop
........
r55374 | brett.cannon | 2007-05-15 21:39:00 -0700 (Tue, 15 May 2007) | 2 lines
Complete the removal of IRIX-specific modules.
........
r55379 | brett.cannon | 2007-05-15 22:31:54 -0700 (Tue, 15 May 2007) | 2 lines
Update removed IRIX modules based on what is gone from removing plat-irix6.
........
r55388 | brett.cannon | 2007-05-16 14:34:52 -0700 (Wed, 16 May 2007) | 2 lines
Clean up the docstring for the compiler resource.
........
r55406 | brett.cannon | 2007-05-17 11:05:37 -0700 (Thu, 17 May 2007) | 2 lines
Remove BaseException.message (deprecated in Python 2.6).
........
Diffstat (limited to 'Lib/test/test_exceptions.py')
-rw-r--r-- | Lib/test/test_exceptions.py | 107 |
1 files changed, 52 insertions, 55 deletions
diff --git a/Lib/test/test_exceptions.py b/Lib/test/test_exceptions.py index b1d6790..64b13b7 100644 --- a/Lib/test/test_exceptions.py +++ b/Lib/test/test_exceptions.py @@ -11,7 +11,6 @@ except ImportError: from test.test_support import (TESTFN, unlink, run_unittest, guard_warnings_filter) -from test.test_pep352 import ignore_message_warning # XXX This is not really enough, each *operation* should be tested! @@ -205,115 +204,113 @@ class ExceptionTests(unittest.TestCase): # test that exception attributes are happy exceptionList = [ - (BaseException, (), {'message' : '', 'args' : ()}), - (BaseException, (1, ), {'message' : 1, 'args' : (1,)}), + (BaseException, (), {'args' : ()}), + (BaseException, (1, ), {'args' : (1,)}), (BaseException, ('foo',), - {'message' : 'foo', 'args' : ('foo',)}), + {'args' : ('foo',)}), (BaseException, ('foo', 1), - {'message' : '', 'args' : ('foo', 1)}), + {'args' : ('foo', 1)}), (SystemExit, ('foo',), - {'message' : 'foo', 'args' : ('foo',), 'code' : 'foo'}), + {'args' : ('foo',), 'code' : 'foo'}), (IOError, ('foo',), - {'message' : 'foo', 'args' : ('foo',), 'filename' : None, + {'args' : ('foo',), 'filename' : None, 'errno' : None, 'strerror' : None}), (IOError, ('foo', 'bar'), - {'message' : '', 'args' : ('foo', 'bar'), 'filename' : None, + {'args' : ('foo', 'bar'), 'filename' : None, 'errno' : 'foo', 'strerror' : 'bar'}), (IOError, ('foo', 'bar', 'baz'), - {'message' : '', 'args' : ('foo', 'bar'), 'filename' : 'baz', + {'args' : ('foo', 'bar'), 'filename' : 'baz', 'errno' : 'foo', 'strerror' : 'bar'}), (IOError, ('foo', 'bar', 'baz', 'quux'), - {'message' : '', 'args' : ('foo', 'bar', 'baz', 'quux')}), + {'args' : ('foo', 'bar', 'baz', 'quux')}), (EnvironmentError, ('errnoStr', 'strErrorStr', 'filenameStr'), - {'message' : '', 'args' : ('errnoStr', 'strErrorStr'), + {'args' : ('errnoStr', 'strErrorStr'), 'strerror' : 'strErrorStr', 'errno' : 'errnoStr', 'filename' : 'filenameStr'}), (EnvironmentError, (1, 'strErrorStr', 'filenameStr'), - {'message' : '', 'args' : (1, 'strErrorStr'), 'errno' : 1, + {'args' : (1, 'strErrorStr'), 'errno' : 1, 'strerror' : 'strErrorStr', 'filename' : 'filenameStr'}), - (SyntaxError, (), {'message' : '', 'msg' : None, 'text' : None, + (SyntaxError, (), {'msg' : None, 'text' : None, 'filename' : None, 'lineno' : None, 'offset' : None, 'print_file_and_line' : None}), (SyntaxError, ('msgStr',), - {'message' : 'msgStr', 'args' : ('msgStr',), 'text' : None, + {'args' : ('msgStr',), 'text' : None, 'print_file_and_line' : None, 'msg' : 'msgStr', 'filename' : None, 'lineno' : None, 'offset' : None}), (SyntaxError, ('msgStr', ('filenameStr', 'linenoStr', 'offsetStr', 'textStr')), - {'message' : '', 'offset' : 'offsetStr', 'text' : 'textStr', + {'offset' : 'offsetStr', 'text' : 'textStr', 'args' : ('msgStr', ('filenameStr', 'linenoStr', 'offsetStr', 'textStr')), 'print_file_and_line' : None, 'msg' : 'msgStr', 'filename' : 'filenameStr', 'lineno' : 'linenoStr'}), (SyntaxError, ('msgStr', 'filenameStr', 'linenoStr', 'offsetStr', 'textStr', 'print_file_and_lineStr'), - {'message' : '', 'text' : None, + {'text' : None, 'args' : ('msgStr', 'filenameStr', 'linenoStr', 'offsetStr', 'textStr', 'print_file_and_lineStr'), 'print_file_and_line' : None, 'msg' : 'msgStr', 'filename' : None, 'lineno' : None, 'offset' : None}), - (UnicodeError, (), {'message' : '', 'args' : (),}), + (UnicodeError, (), {'args' : (),}), (UnicodeEncodeError, (str8('ascii'), 'a', 0, 1, str8('ordinal not in range')), - {'message' : '', 'args' : ('ascii', 'a', 0, 1, + {'args' : ('ascii', 'a', 0, 1, 'ordinal not in range'), 'encoding' : 'ascii', 'object' : 'a', 'start' : 0, 'reason' : 'ordinal not in range'}), (UnicodeDecodeError, (str8('ascii'), b'\xff', 0, 1, str8('ordinal not in range')), - {'message' : '', 'args' : ('ascii', b'\xff', 0, 1, + {'args' : ('ascii', b'\xff', 0, 1, 'ordinal not in range'), 'encoding' : 'ascii', 'object' : b'\xff', 'start' : 0, 'reason' : 'ordinal not in range'}), (UnicodeTranslateError, ("\u3042", 0, 1, str8("ouch")), - {'message' : '', 'args' : ('\u3042', 0, 1, 'ouch'), + {'args' : ('\u3042', 0, 1, 'ouch'), 'object' : '\u3042', 'reason' : 'ouch', 'start' : 0, 'end' : 1}), ] try: exceptionList.append( (WindowsError, (1, 'strErrorStr', 'filenameStr'), - {'message' : '', 'args' : (1, 'strErrorStr'), + {'args' : (1, 'strErrorStr'), 'strerror' : 'strErrorStr', 'winerror' : 1, 'errno' : 22, 'filename' : 'filenameStr'}) ) except NameError: pass - with guard_warnings_filter(): - ignore_message_warning() - for exc, args, expected in exceptionList: - try: - e = exc(*args) - except: - print("\nexc=%r, args=%r" % (exc, args)) - raise - else: - # Verify module name - self.assertEquals(type(e).__module__, '__builtin__') - # Verify no ref leaks in Exc_str() - s = str(e) - for checkArgName in expected: - value = getattr(e, checkArgName) - self.assertEquals(repr(value), - repr(expected[checkArgName]), - '%r.%s == %r, expected %r' % ( - e, checkArgName, - value, expected[checkArgName])) - - # test for pickling support - for p in pickle, cPickle: - if p is None: - continue # cPickle not found -- skip it - for protocol in range(p.HIGHEST_PROTOCOL + 1): - s = p.dumps(e, protocol) - new = p.loads(s) - for checkArgName in expected: - got = repr(getattr(new, checkArgName)) - want = repr(expected[checkArgName]) - self.assertEquals(got, want, - 'pickled "%r", attribute "%s' % - (e, checkArgName)) + for exc, args, expected in exceptionList: + try: + e = exc(*args) + except: + print("\nexc=%r, args=%r" % (exc, args)) + raise + else: + # Verify module name + self.assertEquals(type(e).__module__, '__builtin__') + # Verify no ref leaks in Exc_str() + s = str(e) + for checkArgName in expected: + value = getattr(e, checkArgName) + self.assertEquals(repr(value), + repr(expected[checkArgName]), + '%r.%s == %r, expected %r' % ( + e, checkArgName, + value, expected[checkArgName])) + + # test for pickling support + for p in pickle, cPickle: + if p is None: + continue # cPickle not found -- skip it + for protocol in range(p.HIGHEST_PROTOCOL + 1): + s = p.dumps(e, protocol) + new = p.loads(s) + for checkArgName in expected: + got = repr(getattr(new, checkArgName)) + want = repr(expected[checkArgName]) + self.assertEquals(got, want, + 'pickled "%r", attribute "%s' % + (e, checkArgName)) def testKeywordArgs(self): # test that builtin exception don't take keyword args, |