summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorBatuhan Taskaya <isidentical@gmail.com>2022-04-28 15:18:20 +0300
committerGitHub <noreply@github.com>2022-04-28 05:18:20 -0700
commit419cc2c34ab54cb0cf81e966a49bd5262e44a806 (patch)
tree208368a01f0b0d36fc50cc52bbb9aa0730479dbd /tests
parent79a8ecd84bb9faceeb09c9dcbfc6c2eceebc326a (diff)
Skip on pyOpenSSL (#1376)
Diffstat (limited to 'tests')
-rw-r--r--tests/conftest.py4
-rw-r--r--tests/test_ssl.py7
-rw-r--r--tests/utils/__init__.py2
3 files changed, 7 insertions, 6 deletions
diff --git a/tests/conftest.py b/tests/conftest.py
index 11e0d348..7ca172a8 100644
--- a/tests/conftest.py
+++ b/tests/conftest.py
@@ -1,4 +1,3 @@
-import os
import socket
import pytest
@@ -8,6 +7,7 @@ from .utils import ( # noqa
HTTPBIN_WITH_CHUNKED_SUPPORT_DOMAIN,
HTTPBIN_WITH_CHUNKED_SUPPORT,
REMOTE_HTTPBIN_DOMAIN,
+ IS_PYOPENSSL,
mock_env
)
from .utils.plugins_cli import ( # noqa
@@ -81,7 +81,7 @@ def pyopenssl_inject():
Injects `pyOpenSSL` module to make sure `requests` will use it.
<https://github.com/psf/requests/pull/5443#issuecomment-645740394>
"""
- if os.getenv('HTTPIE_TEST_WITH_PYOPENSSL', '0') == '1':
+ if IS_PYOPENSSL:
try:
import urllib3.contrib.pyopenssl
urllib3.contrib.pyopenssl.inject_into_urllib3()
diff --git a/tests/test_ssl.py b/tests/test_ssl.py
index fc587064..ef72e2be 100644
--- a/tests/test_ssl.py
+++ b/tests/test_ssl.py
@@ -1,4 +1,3 @@
-import os
import ssl
import pytest
@@ -11,7 +10,7 @@ from unittest import mock
from httpie.ssl_ import AVAILABLE_SSL_VERSION_ARG_MAPPING, DEFAULT_SSL_CIPHERS
from httpie.status import ExitStatus
-from .utils import HTTP_OK, TESTS_ROOT, http
+from .utils import HTTP_OK, TESTS_ROOT, IS_PYOPENSSL, http
try:
@@ -152,6 +151,7 @@ def test_ciphers(httpbin_secure):
assert HTTP_OK in r
+@pytest.mark.skipif(IS_PYOPENSSL, reason='pyOpenSSL uses a different message format.')
def test_ciphers_none_can_be_selected(httpbin_secure):
r = http(
httpbin_secure.url + '/get',
@@ -169,8 +169,7 @@ def test_ciphers_none_can_be_selected(httpbin_secure):
def test_pyopenssl_presence():
- using_pyopenssl = os.getenv('HTTPIE_TEST_WITH_PYOPENSSL', '0')
- if using_pyopenssl == '0':
+ if not IS_PYOPENSSL:
assert not urllib3.util.ssl_.IS_PYOPENSSL
assert not urllib3.util.IS_PYOPENSSL
else:
diff --git a/tests/utils/__init__.py b/tests/utils/__init__.py
index 8a575aef..7d2557b6 100644
--- a/tests/utils/__init__.py
+++ b/tests/utils/__init__.py
@@ -1,6 +1,7 @@
"""Utilities for HTTPie test suite."""
import re
import shlex
+import os
import sys
import time
import json
@@ -30,6 +31,7 @@ REMOTE_HTTPBIN_DOMAIN = 'pie.dev'
HTTPBIN_WITH_CHUNKED_SUPPORT_DOMAIN = 'pie.dev'
HTTPBIN_WITH_CHUNKED_SUPPORT = 'http://' + HTTPBIN_WITH_CHUNKED_SUPPORT_DOMAIN
+IS_PYOPENSSL = os.getenv('HTTPIE_TEST_WITH_PYOPENSSL', '0') == '1'
TESTS_ROOT = Path(__file__).parent.parent
CRLF = '\r\n'