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