mirror of
https://github.com/httpie/cli.git
synced 2025-08-17 22:49:40 +02:00
HTTPie v4
This commit is contained in:
@@ -7,7 +7,6 @@ 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
|
||||
@@ -20,6 +19,17 @@ from .utils.plugins_cli import ( # noqa
|
||||
)
|
||||
from .utils.http_server import http_server, localhost_http_server # noqa
|
||||
|
||||
from sys import modules
|
||||
|
||||
import niquests
|
||||
import urllib3
|
||||
|
||||
# the mock utility 'response' only works with 'requests'
|
||||
modules["requests"] = niquests
|
||||
modules["requests.adapters"] = niquests.adapters
|
||||
modules["requests.exceptions"] = niquests.exceptions
|
||||
modules["requests.packages.urllib3"] = urllib3
|
||||
|
||||
|
||||
@pytest.fixture(scope='function', autouse=True)
|
||||
def httpbin_add_ca_bundle(monkeypatch):
|
||||
@@ -73,19 +83,3 @@ def remote_httpbin(_remote_httpbin_available):
|
||||
if _remote_httpbin_available:
|
||||
return 'http://' + REMOTE_HTTPBIN_DOMAIN
|
||||
pytest.skip(f'{REMOTE_HTTPBIN_DOMAIN} not resolvable')
|
||||
|
||||
|
||||
@pytest.fixture(autouse=True, scope='session')
|
||||
def pyopenssl_inject():
|
||||
"""
|
||||
Injects `pyOpenSSL` module to make sure `requests` will use it.
|
||||
<https://github.com/psf/requests/pull/5443#issuecomment-645740394>
|
||||
"""
|
||||
if IS_PYOPENSSL:
|
||||
try:
|
||||
import urllib3.contrib.pyopenssl
|
||||
urllib3.contrib.pyopenssl.inject_into_urllib3()
|
||||
except ModuleNotFoundError:
|
||||
pytest.fail('Missing "pyopenssl" module.')
|
||||
|
||||
yield
|
||||
|
Reference in New Issue
Block a user