mirror of
https://github.com/httpie/cli.git
synced 2024-11-28 08:38:44 +02:00
c000886546
* Preserve individual headers with the same name on responses * Rename RequestHeadersDict to HTTPHeadersDict * Update tests/utils/http_server.py * Update tests/utils/http_server.py * Update httpie/adapters.py Co-authored-by: Jakub Roztocil <jakub@roztocil.co>
63 lines
1.7 KiB
Python
63 lines
1.7 KiB
Python
import os
|
|
import socket
|
|
|
|
import pytest
|
|
from pytest_httpbin import certs
|
|
|
|
from .utils import HTTPBIN_WITH_CHUNKED_SUPPORT_DOMAIN, HTTPBIN_WITH_CHUNKED_SUPPORT
|
|
from .utils.http_server import http_server # noqa
|
|
|
|
|
|
@pytest.fixture(scope='function', autouse=True)
|
|
def httpbin_add_ca_bundle(monkeypatch):
|
|
"""
|
|
Make pytest-httpbin's CA trusted by default.
|
|
|
|
(Same as `httpbin_ca_bundle`, just auto-used.).
|
|
|
|
"""
|
|
monkeypatch.setenv('REQUESTS_CA_BUNDLE', certs.where())
|
|
|
|
|
|
@pytest.fixture(scope='function')
|
|
def httpbin_secure_untrusted(monkeypatch, httpbin_secure):
|
|
"""
|
|
Like the `httpbin_secure` fixture, but without the
|
|
make-CA-trusted-by-default.
|
|
|
|
"""
|
|
monkeypatch.delenv('REQUESTS_CA_BUNDLE')
|
|
return httpbin_secure
|
|
|
|
|
|
@pytest.fixture(scope='session')
|
|
def _httpbin_with_chunked_support_available():
|
|
try:
|
|
socket.gethostbyname(HTTPBIN_WITH_CHUNKED_SUPPORT_DOMAIN)
|
|
return True
|
|
except OSError:
|
|
return False
|
|
|
|
|
|
@pytest.fixture(scope='function')
|
|
def httpbin_with_chunked_support(_httpbin_with_chunked_support_available):
|
|
if _httpbin_with_chunked_support_available:
|
|
return HTTPBIN_WITH_CHUNKED_SUPPORT
|
|
pytest.skip(f'{HTTPBIN_WITH_CHUNKED_SUPPORT_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 os.getenv('HTTPIE_TEST_WITH_PYOPENSSL', '0') == '1':
|
|
try:
|
|
import urllib3.contrib.pyopenssl
|
|
urllib3.contrib.pyopenssl.inject_into_urllib3()
|
|
except ModuleNotFoundError:
|
|
pytest.fail('Missing "pyopenssl" module.')
|
|
|
|
yield
|