diff options
author | Alex Gaynor <alex.gaynor@gmail.com> | 2016-07-31 10:54:24 -0400 |
---|---|---|
committer | Hynek Schlawack <hs@ox.cx> | 2016-07-31 16:54:24 +0200 |
commit | d3b5d9b05c07b322c174270dcda4650659890a85 (patch) | |
tree | 2c89d1597a29cc5bd81fa3888552d475cda4e6b5 | |
parent | 2700b6d7e5f2680d7111d1eb38680139400f22b1 (diff) | |
download | pyopenssl-d3b5d9b05c07b322c174270dcda4650659890a85.tar.gz |
Remove some pointless branches (#511)
* Remove some pointless branches
* this nonsense too
* this is unused
-rw-r--r-- | tests/test_crypto.py | 4 | ||||
-rw-r--r-- | tests/test_ssl.py | 62 |
2 files changed, 20 insertions, 46 deletions
diff --git a/tests/test_crypto.py b/tests/test_crypto.py index 222b9ca..7f83e67 100644 --- a/tests/test_crypto.py +++ b/tests/test_crypto.py @@ -50,10 +50,6 @@ from .util import ( ) -def normalize_certificate_pem(pem): - return dump_certificate(FILETYPE_PEM, load_certificate(FILETYPE_PEM, pem)) - - def normalize_privatekey_pem(pem): return dump_privatekey(FILETYPE_PEM, load_privatekey(FILETYPE_PEM, pem)) diff --git a/tests/test_ssl.py b/tests/test_ssl.py index b0be12b..9f22873 100644 --- a/tests/test_ssl.py +++ b/tests/test_ssl.py @@ -58,28 +58,9 @@ from OpenSSL.SSL import _make_requires from OpenSSL._util import lib as _lib -try: - from OpenSSL.SSL import OP_NO_QUERY_MTU -except ImportError: - OP_NO_QUERY_MTU = None -try: - from OpenSSL.SSL import OP_COOKIE_EXCHANGE -except ImportError: - OP_COOKIE_EXCHANGE = None -try: - from OpenSSL.SSL import OP_NO_TICKET -except ImportError: - OP_NO_TICKET = None - -try: - from OpenSSL.SSL import OP_NO_COMPRESSION -except ImportError: - OP_NO_COMPRESSION = None - -try: - from OpenSSL.SSL import MODE_RELEASE_BUFFERS -except ImportError: - MODE_RELEASE_BUFFERS = None +from OpenSSL.SSL import ( + OP_NO_QUERY_MTU, OP_COOKIE_EXCHANGE, OP_NO_TICKET, OP_NO_COMPRESSION, + MODE_RELEASE_BUFFERS) try: from OpenSSL.SSL import OP_NO_TLSv1, OP_NO_TLSv1_1, OP_NO_TLSv1_2 @@ -816,27 +797,24 @@ class ContextTests(TestCase, _LoopbackMixin): self.assertRaises(TypeError, context.set_mode, None) self.assertRaises(TypeError, context.set_mode, 1, None) - if MODE_RELEASE_BUFFERS is not None: - def test_set_mode(self): - """ - :py:obj:`Context.set_mode` accepts a mode bitvector and returns the - newly set mode. - """ - context = Context(TLSv1_METHOD) - self.assertTrue( - MODE_RELEASE_BUFFERS & context.set_mode(MODE_RELEASE_BUFFERS)) + def test_set_mode(self): + """ + :py:obj:`Context.set_mode` accepts a mode bitvector and returns the + newly set mode. + """ + context = Context(TLSv1_METHOD) + self.assertTrue( + MODE_RELEASE_BUFFERS & context.set_mode(MODE_RELEASE_BUFFERS)) - @skip_if_py3 - def test_set_mode_long(self): - """ - On Python 2 :py:obj:`Context.set_mode` accepts values of type - :py:obj:`long` as well as :py:obj:`int`. - """ - context = Context(TLSv1_METHOD) - mode = context.set_mode(long(MODE_RELEASE_BUFFERS)) - self.assertTrue(MODE_RELEASE_BUFFERS & mode) - else: - "MODE_RELEASE_BUFFERS unavailable - OpenSSL version may be too old" + @skip_if_py3 + def test_set_mode_long(self): + """ + On Python 2 :py:obj:`Context.set_mode` accepts values of type + :py:obj:`long` as well as :py:obj:`int`. + """ + context = Context(TLSv1_METHOD) + mode = context.set_mode(long(MODE_RELEASE_BUFFERS)) + self.assertTrue(MODE_RELEASE_BUFFERS & mode) def test_set_timeout_wrong_args(self): """ |