mirror of
https://github.com/httprunner/httprunner.git
synced 2026-08-28 11:36:56 +08:00
bugfix: In Python3, convert request.data(bytes) to str first
This commit is contained in:
@@ -8,6 +8,12 @@ import yaml
|
|||||||
|
|
||||||
from ate.exception import ParamsError
|
from ate.exception import ParamsError
|
||||||
|
|
||||||
|
try:
|
||||||
|
assert bytes is str
|
||||||
|
PYTHON_VERSION = 2
|
||||||
|
except AssertionError:
|
||||||
|
PYTHON_VERSION = 3
|
||||||
|
|
||||||
|
|
||||||
def gen_random_string(str_len):
|
def gen_random_string(str_len):
|
||||||
return ''.join(
|
return ''.join(
|
||||||
@@ -18,6 +24,11 @@ def gen_md5(str_list):
|
|||||||
return hashlib.md5(authorization_str.encode('utf-8')).hexdigest()
|
return hashlib.md5(authorization_str.encode('utf-8')).hexdigest()
|
||||||
|
|
||||||
def handle_req_data(data):
|
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:
|
if not data:
|
||||||
return data
|
return data
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user