2021-05-27 19:30:36 +02:00
|
|
|
import socket
|
2016-03-06 11:42:35 +02:00
|
|
|
import pytest
|
2018-06-09 11:59:34 +02:00
|
|
|
from pytest_httpbin import certs
|
2016-03-06 11:42:35 +02:00
|
|
|
|
2021-05-27 19:30:36 +02:00
|
|
|
from .utils import HTTPBIN_WITH_CHUNKED_SUPPORT_DOMAIN, HTTPBIN_WITH_CHUNKED_SUPPORT
|
|
|
|
|
2016-03-06 11:42:35 +02:00
|
|
|
|
2018-06-09 11:59:34 +02:00
|
|
|
@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())
|
2016-03-06 11:42:35 +02:00
|
|
|
|
|
|
|
|
|
|
|
@pytest.fixture(scope='function')
|
|
|
|
def httpbin_secure_untrusted(monkeypatch, httpbin_secure):
|
2018-06-09 11:59:34 +02:00
|
|
|
"""
|
|
|
|
Like the `httpbin_secure` fixture, but without the
|
|
|
|
make-CA-trusted-by-default.
|
|
|
|
|
|
|
|
"""
|
2016-03-06 11:42:35 +02:00
|
|
|
monkeypatch.delenv('REQUESTS_CA_BUNDLE')
|
|
|
|
return httpbin_secure
|
2021-05-27 19:30:36 +02:00
|
|
|
|
|
|
|
|
|
|
|
@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('{} not resolvable'.format(HTTPBIN_WITH_CHUNKED_SUPPORT_DOMAIN))
|