diff options
author | Jean-Paul Calderone <exarkun@twistedmatrix.com> | 2014-04-17 16:42:49 -0400 |
---|---|---|
committer | Jean-Paul Calderone <exarkun@twistedmatrix.com> | 2014-04-17 16:42:49 -0400 |
commit | 689c489b124513be3bd0720b384f74d287ea1d76 (patch) | |
tree | a3936c85e8da69c5bc8990d764804bb2da7c4339 | |
parent | 6749ec20140881ee2531e2bb5c87ae8e1dfd9a37 (diff) | |
download | pyopenssl-689c489b124513be3bd0720b384f74d287ea1d76.tar.gz |
Support for Python 2.6 - which lacks addCleanup
-rw-r--r-- | OpenSSL/test/test_ssl.py | 17 |
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): |