summaryrefslogtreecommitdiff
path: root/Lib/test/test_exceptions.py
diff options
context:
space:
mode:
authorGeorg Brandl <georg@python.org>2006-09-06 06:50:05 +0000
committerGeorg Brandl <georg@python.org>2006-09-06 06:50:05 +0000
commit38f6237dfe1355192a11fe004d32f547cd1eadbd (patch)
treeb96e3142445658ff161c1e8c15d7f5e9d7bba2d2 /Lib/test/test_exceptions.py
parentca460d9722c9542004c4cf34d9231641ac18e34b (diff)
downloadcpython-git-38f6237dfe1355192a11fe004d32f547cd1eadbd.tar.gz
Bug #1542051: Exceptions now correctly call PyObject_GC_UnTrack.
Also make sure that every exception class has __module__ set to 'exceptions'.
Diffstat (limited to 'Lib/test/test_exceptions.py')
-rw-r--r--Lib/test/test_exceptions.py39
1 files changed, 13 insertions, 26 deletions
diff --git a/Lib/test/test_exceptions.py b/Lib/test/test_exceptions.py
index ec8895c747..af07aa8aa9 100644
--- a/Lib/test/test_exceptions.py
+++ b/Lib/test/test_exceptions.py
@@ -185,15 +185,6 @@ class ExceptionTests(unittest.TestCase):
def testAttributes(self):
# test that exception attributes are happy
- try:
- str(u'Hello \u00E1')
- except Exception, e:
- sampleUnicodeEncodeError = e
-
- try:
- unicode('\xff')
- except Exception, e:
- sampleUnicodeDecodeError = e
exceptionList = [
(BaseException, (), {'message' : '', 'args' : ()}),
@@ -236,16 +227,16 @@ class ExceptionTests(unittest.TestCase):
'print_file_and_line' : None, 'msg' : 'msgStr',
'filename' : None, 'lineno' : None, 'offset' : None}),
(UnicodeError, (), {'message' : '', 'args' : (),}),
- (sampleUnicodeEncodeError,
- {'message' : '', 'args' : ('ascii', u'Hello \xe1', 6, 7,
- 'ordinal not in range(128)'),
- 'encoding' : 'ascii', 'object' : u'Hello \xe1',
- 'start' : 6, 'reason' : 'ordinal not in range(128)'}),
- (sampleUnicodeDecodeError,
+ (UnicodeEncodeError, ('ascii', u'a', 0, 1, 'ordinal not in range'),
+ {'message' : '', 'args' : ('ascii', u'a', 0, 1,
+ 'ordinal not in range'),
+ 'encoding' : 'ascii', 'object' : u'a',
+ 'start' : 0, 'reason' : 'ordinal not in range'}),
+ (UnicodeDecodeError, ('ascii', '\xff', 0, 1, 'ordinal not in range'),
{'message' : '', 'args' : ('ascii', '\xff', 0, 1,
- 'ordinal not in range(128)'),
+ 'ordinal not in range'),
'encoding' : 'ascii', 'object' : '\xff',
- 'start' : 0, 'reason' : 'ordinal not in range(128)'}),
+ 'start' : 0, 'reason' : 'ordinal not in range'}),
(UnicodeTranslateError, (u"\u3042", 0, 1, "ouch"),
{'message' : '', 'args' : (u'\u3042', 0, 1, 'ouch'),
'object' : u'\u3042', 'reason' : 'ouch',
@@ -261,18 +252,14 @@ class ExceptionTests(unittest.TestCase):
except NameError:
pass
- for args in exceptionList:
- expected = args[-1]
+ for exc, args, expected in exceptionList:
try:
- exc = args[0]
- if len(args) == 2:
- raise exc
- else:
- raise exc(*args[1])
+ raise exc(*args)
except BaseException, e:
- if (e is not exc and # needed for sampleUnicode errors
- type(e) is not exc):
+ if type(e) is not exc:
raise
+ # Verify module name
+ self.assertEquals(type(e).__module__, 'exceptions')
# Verify no ref leaks in Exc_str()
s = str(e)
for checkArgName in expected: