From 689c489b124513be3bd0720b384f74d287ea1d76 Mon Sep 17 00:00:00 2001 From: Jean-Paul Calderone Date: Thu, 17 Apr 2014 16:42:49 -0400 Subject: Support for Python 2.6 - which lacks addCleanup --- OpenSSL/test/test_ssl.py | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/OpenSSL/test/test_ssl.py b/OpenSSL/test/test_ssl.py index db33afb..5e9fd83 100644 --- a/OpenSSL/test/test_ssl.py +++ b/OpenSSL/test/test_ssl.py @@ -1192,15 +1192,16 @@ class ContextTests(TestCase, _LoopbackMixin): elliptic curve support is not available from the underlying OpenSSL version at all. """ - self.addCleanup( - setattr, - _lib, "Cryptography_HAS_EC", _lib.Cryptography_HAS_EC) - _lib.Cryptography_HAS_EC = False + has_ec = _lib.Cryptography_HAS_EC + try: + _lib.Cryptography_HAS_EC = False - context = Context(TLSv1_METHOD) - self.assertRaises( - ECNotAvailable, - context.set_tmp_ecdh_curve, next(iter(ELLIPTIC_CURVE_DESCRIPTIONS))) + context = Context(TLSv1_METHOD) + self.assertRaises( + ECNotAvailable, + context.set_tmp_ecdh_curve, next(iter(ELLIPTIC_CURVE_DESCRIPTIONS))) + finally: + _lib.Cryptography_HAS_EC = has_ec def test_set_tmp_ecdh_curve_bad_sn(self): -- cgit v1.2.1