/usr/lib/python2.7/dist-packages/betamax/matchers/body.py is in python-betamax 0.5.1-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 | # -*- coding: utf-8 -*-
from .base import BaseMatcher
from ..cassette.util import deserialize_prepared_request
class BodyMatcher(BaseMatcher):
# Matches based on the body of the request
name = 'body'
def match(self, request, recorded_request):
recorded_request = deserialize_prepared_request(recorded_request)
if request.body:
if isinstance(recorded_request.body, type(request.body)):
request_body = request.body
else:
request_body = request.body.encode('utf-8')
else:
request_body = b''
return recorded_request.body == request_body
|