diff options
author | Richard Oudkerk <shibturn@gmail.com> | 2012-07-28 16:45:28 (GMT) |
---|---|---|
committer | Richard Oudkerk <shibturn@gmail.com> | 2012-07-28 16:45:28 (GMT) |
commit | 5562d9dc5dd9f9a7710a1530a114c215516d4700 (patch) | |
tree | 506ef5c564f175f3760a1aee6b37490d1a67b6d5 /Lib/test/test_exceptions.py | |
parent | e4c0799d9c5359b9c5115adf212d452137683c57 (diff) | |
download | cpython-5562d9dc5dd9f9a7710a1530a114c215516d4700.zip cpython-5562d9dc5dd9f9a7710a1530a114c215516d4700.tar.gz cpython-5562d9dc5dd9f9a7710a1530a114c215516d4700.tar.bz2 |
Issue #1692335: Move initial args assignment to BaseException.__new__
to help pickling of naive subclasses.
Diffstat (limited to 'Lib/test/test_exceptions.py')
-rw-r--r-- | Lib/test/test_exceptions.py | 16 |
1 files changed, 15 insertions, 1 deletions
diff --git a/Lib/test/test_exceptions.py b/Lib/test/test_exceptions.py index 97762f9..0b1fd1b 100644 --- a/Lib/test/test_exceptions.py +++ b/Lib/test/test_exceptions.py @@ -10,6 +10,15 @@ import errno from test.support import (TESTFN, unlink, run_unittest, captured_output, gc_collect, cpython_only, no_tracing) +class NaiveException(Exception): + def __init__(self, x): + self.x = x + +class SlottedNaiveException(Exception): + __slots__ = ('x',) + def __init__(self, x): + self.x = x + # XXX This is not really enough, each *operation* should be tested! class ExceptionTests(unittest.TestCase): @@ -296,6 +305,10 @@ class ExceptionTests(unittest.TestCase): {'args' : ('\u3042', 0, 1, 'ouch'), 'object' : '\u3042', 'reason' : 'ouch', 'start' : 0, 'end' : 1}), + (NaiveException, ('foo',), + {'args': ('foo',), 'x': 'foo'}), + (SlottedNaiveException, ('foo',), + {'args': ('foo',), 'x': 'foo'}), ] try: # More tests are in test_WindowsError @@ -316,7 +329,8 @@ class ExceptionTests(unittest.TestCase): raise else: # Verify module name - self.assertEqual(type(e).__module__, 'builtins') + if not type(e).__name__.endswith('NaiveException'): + self.assertEqual(type(e).__module__, 'builtins') # Verify no ref leaks in Exc_str() s = str(e) for checkArgName in expected: |