Skip to content

Commit

Permalink
Fix python3 betamax body comparision.
Browse files Browse the repository at this point in the history
  • Loading branch information
bboe committed Apr 11, 2015
1 parent 9c1f5ef commit 1843f74
Showing 1 changed file with 16 additions and 2 deletions.
18 changes: 16 additions & 2 deletions tests/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@
import unittest
import uuid
import warnings
from betamax import Betamax
from betamax import Betamax, BaseMatcher
from betamax.cassette.util import deserialize_prepared_request
from functools import wraps
from requests.compat import urljoin
from requests.exceptions import HTTPError
Expand All @@ -40,9 +41,22 @@

USER_AGENT = 'PRAW_test_suite'


class ByteBodyMatcher(BaseMatcher):
name = 'ByteBody'

def match(self, request, recorded_request):
recorded_request = deserialize_prepared_request(recorded_request)
return recorded_request.body == (request.body or b'')

Betamax.register_request_matcher(ByteBodyMatcher)


with Betamax.configure() as config:
config.cassette_library_dir = 'tests/fixtures/cassettes'
config.default_cassette_options['match_requests_on'].append('body')
config.default_cassette_options['match_requests_on'].append('ByteBody')




def flair_diff(root, other):
Expand Down

0 comments on commit 1843f74

Please sign in to comment.