Skip to content

Commit

Permalink
Fix body matcher again.
Browse files Browse the repository at this point in the history
  • Loading branch information
bboe committed Apr 11, 2015
1 parent abc9cc7 commit afb2e87
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions tests/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,14 +42,20 @@
USER_AGENT = 'PRAW_test_suite'


class ByteBodyMatcher(BaseMatcher):
class BodyMatcher(BaseMatcher):
name = 'ByteBody'

def match(self, request, recorded_request):
recorded_request = deserialize_prepared_request(recorded_request)
return recorded_request.body == (request.body or b'')
prev_body = deserialize_prepared_request(recorded_request).body
if not prev_body and not request.body:
return True

Betamax.register_request_matcher(ByteBodyMatcher)
def parts(params):
return sorted(params.split('&'))

return parts(prev_body) == parts(request.body)

Betamax.register_request_matcher(BodyMatcher)


with Betamax.configure() as config:
Expand Down

0 comments on commit afb2e87

Please sign in to comment.