mirror of
https://github.com/kevin1024/vcrpy.git
synced 2025-12-08 16:53:23 +00:00
fixes before_record_response mutates response
When no cassette exists, it's expected that the response returned, should be the original, unchanged response. The response recorded in the cassette should be that which is returned by the before_record_response callback. But on subsequent requests/responses (when a cassette exists), the responses returned should be exactly what is in the cassette. resolves #355
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
import collections
|
||||
import copy
|
||||
import sys
|
||||
import inspect
|
||||
import logging
|
||||
@@ -222,6 +223,9 @@ class Cassette(object):
|
||||
request = self._before_record_request(request)
|
||||
if not request:
|
||||
return
|
||||
# Deepcopy is here because mutation of `response` will corrupt the
|
||||
# real response.
|
||||
response = copy.deepcopy(response)
|
||||
response = self._before_record_response(response)
|
||||
if response is None:
|
||||
return
|
||||
|
||||
Reference in New Issue
Block a user