From: Christian Heimes Date: Mon, 1 Jul 2013 21:00:13 +0000 (+0200) Subject: Issue #18339: use with self.assertRaises() to make test case more readable X-Git-Tag: v3.4.0a1~345^2 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=21782488584f7b633f4a6f125e6ba200c016d644;p=python Issue #18339: use with self.assertRaises() to make test case more readable --- diff --git a/Lib/test/test_pickle.py b/Lib/test/test_pickle.py index e96fe523df..fbe96ac2a8 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):