diff options
author | Serhiy Storchaka <storchaka@gmail.com> | 2015-11-29 14:13:51 (GMT) |
---|---|---|
committer | Serhiy Storchaka <storchaka@gmail.com> | 2015-11-29 14:13:51 (GMT) |
commit | d26b66313eb0197aadb7a463ae3bc8b76f504a74 (patch) | |
tree | 5c25cca8a92be492d7f4fdc9ca84f15ae4f8c093 /Lib | |
parent | bf19ce27c44c7bb7ba45cfa18a26132a9e6bf2ca (diff) | |
download | cpython-d26b66313eb0197aadb7a463ae3bc8b76f504a74.zip cpython-d26b66313eb0197aadb7a463ae3bc8b76f504a74.tar.gz cpython-d26b66313eb0197aadb7a463ae3bc8b76f504a74.tar.bz2 |
Got rid of "with" for compatibility test_xpickle with Python 2.5.
Diffstat (limited to 'Lib')
-rw-r--r-- | Lib/test/pickletester.py | 15 |
1 files changed, 11 insertions, 4 deletions
diff --git a/Lib/test/pickletester.py b/Lib/test/pickletester.py index 96df135..267d3f0 100644 --- a/Lib/test/pickletester.py +++ b/Lib/test/pickletester.py @@ -476,15 +476,22 @@ class AbstractUnpickleTests(unittest.TestCase): getattr(objcopy, slot, None), msg=msg) def check_unpickling_error(self, errors, data): - with self.assertRaises(errors): + try: try: self.loads(data) except: if support.verbose > 1: - exc = sys.exc_info()[1] - print('%-32r - %s: %s' % - (data, exc.__class__.__name__, exc)) + exc_type, exc, tb = sys.exc_info() + print '%-32r - %s: %s' % (data, exc_type.__name__, exc) raise + except errors: + pass + else: + try: + exc_name = errors.__name__ + except AttributeError: + exc_name = str(errors) + raise self.failureException('%s not raised' % exc_name) def test_load_from_canned_string(self): expected = self._testdata |