mirror of
https://github.com/openSUSE/osc.git
synced 2025-02-03 01:56:17 +01:00
tests.common: req.data can also be a file-like object
This commit is contained in:
parent
c53a7681ef
commit
502dbaa030
@ -93,8 +93,11 @@ class MyHTTPHandler(HTTPHandler):
|
|||||||
raise RuntimeError('exp or expfile required')
|
raise RuntimeError('exp or expfile required')
|
||||||
if exp is not None:
|
if exp is not None:
|
||||||
# use req.data instead of req.get_data() for python3 compatiblity
|
# use req.data instead of req.get_data() for python3 compatiblity
|
||||||
if req.data != bytes(exp, "utf-8"):
|
data = req.data
|
||||||
raise RequestDataMismatch(req.get_full_url(), repr(req.get_data()), repr(exp))
|
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)
|
return self.__get_response(req.get_full_url(), **kwargs)
|
||||||
|
|
||||||
def __get_response(self, url, **kwargs):
|
def __get_response(self, url, **kwargs):
|
||||||
|
Loading…
Reference in New Issue
Block a user