Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions src/requests/adapters.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand All @@ -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):
Expand Down
17 changes: 7 additions & 10 deletions tests/test_requests.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down Expand Up @@ -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):
Expand Down
Loading