bugfix: In Python3, convert request.data(bytes) to str first

This commit is contained in:
debugtalk
2017-06-24 12:13:27 +08:00
parent db68c394e8
commit b90dabf151

View File

@@ -8,6 +8,12 @@ import yaml
from ate.exception import ParamsError
try:
assert bytes is str
PYTHON_VERSION = 2
except AssertionError:
PYTHON_VERSION = 3
def gen_random_string(str_len):
return ''.join(
@@ -18,6 +24,11 @@ def gen_md5(str_list):
return hashlib.md5(authorization_str.encode('utf-8')).hexdigest()
def handle_req_data(data):
if PYTHON_VERSION == 3 and isinstance(data, bytes):
# In Python3, convert bytes to str
data = data.decode('utf-8')
if not data:
return data