mirror of
https://github.com/kevin1024/vcrpy.git
synced 2025-12-08 16:53:23 +00:00
Improve string format
This commit is contained in:
@@ -64,8 +64,9 @@ def test_CannotOverwriteExistingCassetteException_get_message(
|
||||
failed_request = "request"
|
||||
exception_message = errors.CannotOverwriteExistingCassetteException._get_message(cassette, "request")
|
||||
expected = (
|
||||
"Can't overwrite existing cassette ({!r}) in your current record mode ({!r}).\n"
|
||||
"No match for the request ({!r}) was found.\n"
|
||||
"{}".format(cassette._path, cassette.record_mode, failed_request, expected_message)
|
||||
f"Can't overwrite existing cassette ({cassette._path!r}) "
|
||||
f"in your current record mode ({cassette.record_mode!r}).\n"
|
||||
f"No match for the request ({failed_request!r}) was found.\n"
|
||||
f"{expected_message}"
|
||||
)
|
||||
assert exception_message == expected
|
||||
|
||||
@@ -13,9 +13,9 @@ class CannotOverwriteExistingCassetteException(Exception):
|
||||
best_matches = cassette.find_requests_with_most_matches(failed_request)
|
||||
if best_matches:
|
||||
# Build a comprehensible message to put in the exception.
|
||||
best_matches_msg = "Found {} similar requests with {} different matcher(s) :\n".format(
|
||||
len(best_matches),
|
||||
len(best_matches[0][2]),
|
||||
best_matches_msg = (
|
||||
f"Found {len(best_matches)} similar requests "
|
||||
f"with {len(best_matches[0][2])} different matcher(s) :\n"
|
||||
)
|
||||
|
||||
for idx, best_match in enumerate(best_matches, start=1):
|
||||
@@ -30,10 +30,10 @@ class CannotOverwriteExistingCassetteException(Exception):
|
||||
else:
|
||||
best_matches_msg = "No similar requests, that have not been played, found."
|
||||
return (
|
||||
"Can't overwrite existing cassette ({!r}) in "
|
||||
"your current record mode ({!r}).\n"
|
||||
"No match for the request ({!r}) was found.\n"
|
||||
"{}".format(cassette._path, cassette.record_mode, failed_request, best_matches_msg)
|
||||
f"Can't overwrite existing cassette ({cassette._path!r}) in "
|
||||
f"your current record mode ({cassette.record_mode!r}).\n"
|
||||
f"No match for the request ({failed_request!r}) was found.\n"
|
||||
f"{best_matches_msg}"
|
||||
)
|
||||
|
||||
|
||||
|
||||
@@ -29,9 +29,9 @@ def vcr_fetch_impl(cassette, real_fetch_impl):
|
||||
request,
|
||||
599,
|
||||
error=Exception(
|
||||
"The request (%s) uses AsyncHTTPClient functionality "
|
||||
f"The request ({request!r}) uses AsyncHTTPClient functionality "
|
||||
"that is not yet supported by VCR.py. Please make the "
|
||||
"request outside a VCR.py context." % repr(request),
|
||||
"request outside a VCR.py context.",
|
||||
),
|
||||
request_time=self.io_loop.time() - request.start_time,
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user