1
0
mirror of https://github.com/openSUSE/osc.git synced 2024-11-12 23:56:13 +01:00

tests.common: req.data can also be a file-like object

This commit is contained in:
Marcus Huewe 2016-05-29 16:19:43 +02:00
parent c53a7681ef
commit 502dbaa030

View File

@ -93,8 +93,11 @@ class MyHTTPHandler(HTTPHandler):
raise RuntimeError('exp or expfile required')
if exp is not None:
# use req.data instead of req.get_data() for python3 compatiblity
if req.data != bytes(exp, "utf-8"):
raise RequestDataMismatch(req.get_full_url(), repr(req.get_data()), repr(exp))
data = req.data
if hasattr(data, 'read'):
data = data.read()
if data != bytes(exp, "utf-8"):
raise RequestDataMismatch(req.get_full_url(), repr(data), repr(exp))
return self.__get_response(req.get_full_url(), **kwargs)
def __get_response(self, url, **kwargs):