From 21782488584f7b633f4a6f125e6ba200c016d644 Mon Sep 17 00:00:00 2001 From: Christian Heimes Date: Mon, 1 Jul 2013 23:00:13 +0200 Subject: [PATCH] Issue #18339: use with self.assertRaises() to make test case more readable --- Lib/test/test_pickle.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/Lib/test/test_pickle.py b/Lib/test/test_pickle.py index e96fe523df7..fbe96ac2a81 100644 --- a/Lib/test/test_pickle.py +++ b/Lib/test/test_pickle.py @@ -117,9 +117,11 @@ if has_c_implementation: def test_issue18339(self): unpickler = self.unpickler_class(io.BytesIO()) - self.assertRaises(TypeError, setattr, unpickler, "memo", object) + with self.assertRaises(TypeError): + unpickler.memo = object # used to cause a segfault - self.assertRaises(ValueError, setattr, unpickler, "memo", {-1: None}) + with self.assertRaises(ValueError): + unpickler.memo = {-1: None} unpickler.memo = {1: None} class CDispatchTableTests(AbstractDispatchTableTests):