summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJean-Paul Calderone <exarkun@twistedmatrix.com>2014-04-17 16:42:49 -0400
committerJean-Paul Calderone <exarkun@twistedmatrix.com>2014-04-17 16:42:49 -0400
commit689c489b124513be3bd0720b384f74d287ea1d76 (patch)
treea3936c85e8da69c5bc8990d764804bb2da7c4339
parent6749ec20140881ee2531e2bb5c87ae8e1dfd9a37 (diff)
downloadpyopenssl-689c489b124513be3bd0720b384f74d287ea1d76.tar.gz
Support for Python 2.6 - which lacks addCleanup
-rw-r--r--OpenSSL/test/test_ssl.py17
1 files 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):