diff --git a/src/requests/adapters.py b/src/requests/adapters.py index 6d5951f251..257735179e 100644 --- a/src/requests/adapters.py +++ b/src/requests/adapters.py @@ -327,7 +327,7 @@ def cert_verify(self, conn, url, verify, cert): if not os.path.exists(cert_loc): raise OSError( f"Could not find a suitable TLS CA certificate bundle, " - f"invalid path: {cert_loc}" + f"invalid path: {cert_loc!r}" ) if not os.path.isdir(cert_loc): @@ -349,11 +349,11 @@ def cert_verify(self, conn, url, verify, cert): if conn.cert_file and not os.path.exists(conn.cert_file): raise OSError( f"Could not find the TLS certificate file, " - f"invalid path: {conn.cert_file}" + f"invalid path: {conn.cert_file!r}" ) if conn.key_file and not os.path.exists(conn.key_file): raise OSError( - f"Could not find the TLS key file, invalid path: {conn.key_file}" + f"Could not find the TLS key file, invalid path: {conn.key_file!r}" ) def build_response(self, req, resp): diff --git a/tests/test_requests.py b/tests/test_requests.py index 75d2deff2e..2f65368ad7 100644 --- a/tests/test_requests.py +++ b/tests/test_requests.py @@ -960,26 +960,24 @@ def test_invalid_ca_certificate_path(self, httpbin_secure): INVALID_PATH = "/garbage" with pytest.raises(IOError) as e: requests.get(httpbin_secure(), verify=INVALID_PATH) - assert str( - e.value - ) == "Could not find a suitable TLS CA certificate bundle, invalid path: {}".format( - INVALID_PATH + assert ( + str(e.value) + == f"Could not find a suitable TLS CA certificate bundle, invalid path: {INVALID_PATH!r}" ) def test_invalid_ssl_certificate_files(self, httpbin_secure): INVALID_PATH = "/garbage" with pytest.raises(IOError) as e: requests.get(httpbin_secure(), cert=INVALID_PATH) - assert str( - e.value - ) == "Could not find the TLS certificate file, invalid path: {}".format( - INVALID_PATH + assert ( + str(e.value) + == f"Could not find the TLS certificate file, invalid path: {INVALID_PATH!r}" ) with pytest.raises(IOError) as e: requests.get(httpbin_secure(), cert=(".", INVALID_PATH)) assert str(e.value) == ( - f"Could not find the TLS key file, invalid path: {INVALID_PATH}" + f"Could not find the TLS key file, invalid path: {INVALID_PATH!r}" ) @pytest.mark.parametrize( @@ -2460,7 +2458,6 @@ def test_expires_none(self): class TestMorselToCookieMaxAge: - """Tests for morsel_to_cookie when morsel contains max-age.""" def test_max_age_valid_int(self):