Add type hints to test.with_dummyserver.test_integration
MODIFY
noxfile.py
noxfile.py
@@ -168,6 +168,7 @@ def mypy(session: nox.Session) -> None:
"src/urllib3",
"test/__init__.py",
"test/with_dummyserver/test_https.py",
+ "test/with_dummyserver/test_integration.py",
"test/conftest.py",
"test/contrib/test_pyopenssl_dependencies.py",
"test/contrib/test_socks.py",

MODIFY
test/with_dummyserver/test_integration.py
test/with_dummyserver/test_integration.py
@@ -6,7 +6,7 @@ from dummyserver.testcase import HTTPDummyServerTestCase, HTTPSDummyServerTestCa
class TestHTTPIntegration(HTTPDummyServerTestCase):
- def test_requests_integration(self):
+ def test_requests_integration(self) -> None:
with pytest.warns(DeprecationWarning) as records:
response = requests.get(f"{self.scheme}://{self.host}:{self.port}")
@@ -15,11 +15,14 @@ class TestHTTPIntegration(HTTPDummyServerTestCase):
"The 'strict' parameter is no longer needed on Python 3+. "
"This will raise an error in urllib3 v3.0.0."
)
- assert any(record.message.args[0] == msg for record in records)
+ assert any(
+ isinstance(record.message, Warning) and record.message.args[0] == msg
+ for record in records
+ )
class TestHTTPSIntegration(HTTPSDummyServerTestCase):
- def test_requests_integration(self):
+ def test_requests_integration(self) -> None:
with pytest.warns(DeprecationWarning) as records:
response = requests.get(
f"{self.scheme}://{self.host}:{self.port}", verify=DEFAULT_CA
@@ -30,4 +33,7 @@ class TestHTTPSIntegration(HTTPSDummyServerTestCase):
"The 'strict' parameter is no longer needed on Python 3+. "
"This will raise an error in urllib3 v3.0.0."
)
- assert any(record.message.args[0] == msg for record in records)
+ assert any(
+ isinstance(record.message, Warning) and record.message.args[0] == msg
+ for record in records
+ )

Add type hints to test.with_dummyserver.test_integration