Fix memory leak when comparing requests (#6764)

This commit is contained in:
Mike Lee 2023-09-06 00:50:47 +10:00 committed by GitHub
parent cfb3e428d3
commit 7f3a69b7a5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -26,9 +26,11 @@ class CustomRegistry(responses.registries.FirstMatchRegistry):
self._registered.clear()
def find(self, request: Any) -> Tuple[Optional[responses.BaseResponse], List[str]]:
all_possibles = responses._default_mock._registry.registered
# We don't have to search through all possible methods - only the ones registered for this particular method
all_possibles.extend(self._registered[request.method])
all_possibles = (
responses._default_mock._registry.registered
+ self._registered[request.method]
)
found = []
match_failed_reasons = []
for response in all_possibles: