Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit d91d623

Browse files
committed
Fixing Python3 support for encoding mocked payloads.
1 parent 5030836 commit d91d623

File tree

2 files changed

+9
-9
lines changed

2 files changed

+9
-9
lines changed

tests/unit/test_request.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ def it_raises_an_unexpected_typed_error(self):
8282
}
8383
]
8484
}
85-
content = json.dumps(payload)
85+
content = json.dumps(payload).encode('utf-8')
8686
resp = Mock(content=content, status_code=200, headers=headers)
8787
with patch('requests.request') as mock_method:
8888
mock_method.return_value = resp
@@ -104,7 +104,7 @@ def it_raises_an_unexpected_untyped_error(self):
104104
}
105105
]
106106
}
107-
content = json.dumps(payload)
107+
content = json.dumps(payload).encode('utf-8')
108108
resp = Mock(content=content, status_code=200, headers=headers)
109109
with patch('requests.request') as mock_method:
110110
mock_method.return_value = resp
@@ -130,7 +130,7 @@ def it_raises_a_bad_request_error(self):
130130
for code in ['missing_parameter', 'parameter_invalid', 'bad_request']:
131131
payload['errors'][0]['type'] = code
132132

133-
content = json.dumps(payload)
133+
content = json.dumps(payload).encode('utf-8')
134134
resp = Mock(content=content, status_code=200, headers=headers)
135135
with patch('requests.request') as mock_method:
136136
mock_method.return_value = resp
@@ -151,7 +151,7 @@ def it_raises_an_authentication_error(self):
151151
for code in ['unauthorized', 'forbidden']:
152152
payload['errors'][0]['type'] = code
153153

154-
content = json.dumps(payload)
154+
content = json.dumps(payload).encode('utf-8')
155155
resp = Mock(content=content, status_code=200, headers=headers)
156156
with patch('requests.request') as mock_method:
157157
mock_method.return_value = resp
@@ -169,7 +169,7 @@ def it_raises_resource_not_found_by_type(self):
169169
}
170170
]
171171
}
172-
content = json.dumps(payload)
172+
content = json.dumps(payload).encode('utf-8')
173173
resp = Mock(content=content, status_code=200, headers=headers)
174174
with patch('requests.request') as mock_method:
175175
mock_method.return_value = resp
@@ -187,7 +187,7 @@ def it_raises_rate_limit_exceeded(self):
187187
}
188188
]
189189
}
190-
content = json.dumps(payload)
190+
content = json.dumps(payload).encode('utf-8')
191191
resp = Mock(content=content, status_code=200, headers=headers)
192192
with patch('requests.request') as mock_method:
193193
mock_method.return_value = resp
@@ -205,7 +205,7 @@ def it_raises_a_service_unavailable_error(self):
205205
}
206206
]
207207
}
208-
content = json.dumps(payload)
208+
content = json.dumps(payload).encode('utf-8')
209209
resp = Mock(content=content, status_code=200, headers=headers)
210210
with patch('requests.request') as mock_method:
211211
mock_method.return_value = resp
@@ -223,7 +223,7 @@ def it_raises_a_multiple_matching_users_error(self):
223223
}
224224
]
225225
}
226-
content = json.dumps(payload)
226+
content = json.dumps(payload).encode('utf-8')
227227
resp = Mock(content=content, status_code=200, headers=headers)
228228
with patch('requests.request') as mock_method:
229229
mock_method.return_value = resp

tests/unit/test_user.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -361,7 +361,7 @@ def it_raises_a_multiple_matching_users_error_when_receiving_a_conflict(self):
361361
'x-ratelimit-remaining': 500,
362362
'x-ratelimit-reset': 1427932858
363363
}
364-
content = json.dumps(payload)
364+
content = json.dumps(payload).encode('utf-8')
365365
resp = Mock(content=content, status_code=200, headers=headers)
366366
with patch('requests.request') as mock_method:
367367
mock_method.return_value = resp

0 commit comments

Comments
 (0)