mirror of
https://github.com/kennethreitz/requests.git
synced 2026-06-05 06:46:15 +00:00
Support missing SNIMissingWarning in tests (#6336)
This commit is contained in:
+9
-5
@@ -2,9 +2,13 @@
|
||||
|
||||
import warnings
|
||||
|
||||
from urllib3.exceptions import SNIMissingWarning
|
||||
try:
|
||||
from urllib3.exceptions import SNIMissingWarning
|
||||
|
||||
# urllib3 sets SNIMissingWarning to only go off once,
|
||||
# while this test suite requires it to always fire
|
||||
# so that it occurs during test_requests.test_https_warnings
|
||||
warnings.simplefilter("always", SNIMissingWarning)
|
||||
# urllib3 1.x sets SNIMissingWarning to only go off once,
|
||||
# while this test suite requires it to always fire
|
||||
# so that it occurs during test_requests.test_https_warnings
|
||||
warnings.simplefilter("always", SNIMissingWarning)
|
||||
except ImportError:
|
||||
# urllib3 2.0 removed that warning and errors out instead
|
||||
SNIMissingWarning = None
|
||||
|
||||
@@ -48,6 +48,7 @@ from requests.models import PreparedRequest, urlencode
|
||||
from requests.sessions import SessionRedirectMixin
|
||||
from requests.structures import CaseInsensitiveDict
|
||||
|
||||
from . import SNIMissingWarning
|
||||
from .compat import StringIO
|
||||
from .utils import override_environ
|
||||
|
||||
@@ -974,6 +975,10 @@ class TestRequests:
|
||||
r = requests.get(httpbin(), cert=".")
|
||||
assert r.status_code == 200
|
||||
|
||||
@pytest.mark.skipif(
|
||||
SNIMissingWarning is None,
|
||||
reason="urllib3 2.0 removed that warning and errors out instead",
|
||||
)
|
||||
def test_https_warnings(self, nosan_server):
|
||||
"""warnings are emitted with requests.get"""
|
||||
host, port, ca_bundle = nosan_server
|
||||
|
||||
Reference in New Issue
Block a user