mirror of
https://github.com/httprunner/httprunner.git
synced 2026-05-11 18:11:21 +08:00
bugfix: In Python3, convert request.data(bytes) to str first
This commit is contained in:
11
ate/utils.py
11
ate/utils.py
@@ -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
|
||||
|
||||
|
||||
Reference in New Issue
Block a user