Close the HTTP error fixtures when the test ends
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -106,15 +106,16 @@ class TestFetchArtists(unittest.TestCase):
|
|||||||
= json.dumps(payload).encode("utf-8")
|
= json.dumps(payload).encode("utf-8")
|
||||||
return response
|
return response
|
||||||
|
|
||||||
@staticmethod
|
def __http_error(self, status: int) -> urllib.error.HTTPError:
|
||||||
def __http_error(status: int) -> urllib.error.HTTPError:
|
"""Build an HTTP error, closed when the test ends.
|
||||||
"""Build an HTTP error.
|
|
||||||
|
|
||||||
:param status: The HTTP status code.
|
:param status: The HTTP status code.
|
||||||
:return: The HTTP error.
|
:return: The HTTP error.
|
||||||
"""
|
"""
|
||||||
return urllib.error.HTTPError(
|
error: urllib.error.HTTPError = urllib.error.HTTPError(
|
||||||
"https://example.com/", status, "Error", None, None)
|
"https://example.com/", status, "Error", None, None)
|
||||||
|
self.addCleanup(error.close)
|
||||||
|
return error
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def __claim(qid: str) -> dict[str, Any]:
|
def __claim(qid: str) -> dict[str, Any]:
|
||||||
|
|||||||
@@ -112,14 +112,15 @@ class TestFetchLyrics(unittest.TestCase):
|
|||||||
= json.dumps(payload).encode("utf-8")
|
= json.dumps(payload).encode("utf-8")
|
||||||
return response
|
return response
|
||||||
|
|
||||||
@staticmethod
|
def __not_found(self) -> urllib.error.HTTPError:
|
||||||
def __not_found() -> urllib.error.HTTPError:
|
"""Build an HTTP 404 error, closed when the test ends.
|
||||||
"""Build an HTTP 404 error.
|
|
||||||
|
|
||||||
:return: The HTTP 404 error.
|
:return: The HTTP 404 error.
|
||||||
"""
|
"""
|
||||||
return urllib.error.HTTPError(
|
error: urllib.error.HTTPError = urllib.error.HTTPError(
|
||||||
"https://example.com/", 404, "Not Found", None, None)
|
"https://example.com/", 404, "Not Found", None, None)
|
||||||
|
self.addCleanup(error.close)
|
||||||
|
return error
|
||||||
|
|
||||||
def __run_fetch(self) -> tuple[int, str]:
|
def __run_fetch(self) -> tuple[int, str]:
|
||||||
"""Run the fetcher with the standard error captured.
|
"""Run the fetcher with the standard error captured.
|
||||||
|
|||||||
Reference in New Issue
Block a user