def execute(self, response):
"""Generates fixture objects from the given response and stores them
in the application-specific cache.
:param response: the recorded :class:`Response`
"""
if not has_request_context:
return
self._fallback_fixture_names()
try:
app = self.auto_fixture.app
# Create response fixture
fixture = Fixture.from_response(response, app, self.response_name)
self.auto_fixture.add_fixture(fixture)
# Create request fixture
if request.data:
fixture = Fixture.from_request(request, app, self.request_name)
self.auto_fixture.add_fixture(fixture)
except TypeError: # pragma: no cover
warnings.warn("Could not create fixture for unsupported mime type")
return response
评论列表
文章目录