Skip to content

Commit

Permalink
wip: attempt to fix my BeforeRecordResponse
Browse files Browse the repository at this point in the history
Hit a pytest-vcr bug? ktosiek/pytest-vcr#46
  • Loading branch information
rkhwaja committed Dec 24, 2021
1 parent 6ebdfdc commit 865f44b
Showing 1 changed file with 12 additions and 7 deletions.
19 changes: 12 additions & 7 deletions tests/test_main.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,18 @@ def CheckOutput(items, prefix):

def ScrubStrings(stringReplacementPairs):
def BeforeRecordResponse(response):
for string, replacement in stringReplacementPairs:
response['body']['string'] = response['body']['string'].replace(string.encode(), replacement.encode())
if 'headers' in response and 'Set-Cookie' in response['headers']:
cookies = []
for cookie in response['headers']['Set-Cookie']:
cookies.append(cookie.replace(string, replacement))
response['headers']['Set-Cookie'] = cookies
from logging import info
info(type(response))
info(list(response.keys()))
# info(response['body'])
if 'body' in response:
for string, replacement in stringReplacementPairs:
response['body']['string'] = response['body']['string'].replace(string.encode(), replacement.encode())
if 'headers' in response and 'Set-Cookie' in response['headers']:
cookies = []
for cookie in response['headers']['Set-Cookie']:
cookies.append(cookie.replace(string, replacement))
response['headers']['Set-Cookie'] = cookies
return response
return BeforeRecordResponse

Expand Down

0 comments on commit 865f44b

Please sign in to comment.