mirror of
https://github.com/httprunner/httprunner.git
synced 2026-09-05 07:26:55 +08:00
bugfix: make compatible with Python 2.7
This commit is contained in:
@@ -4,9 +4,9 @@ import json
|
|||||||
import re
|
import re
|
||||||
|
|
||||||
from httprunner import exceptions, logger, testcase, utils
|
from httprunner import exceptions, logger, testcase, utils
|
||||||
from httprunner.compat import OrderedDict, basestring
|
from httprunner.compat import OrderedDict, basestring, is_py2
|
||||||
from requests.structures import CaseInsensitiveDict
|
|
||||||
from requests.models import PreparedRequest
|
from requests.models import PreparedRequest
|
||||||
|
from requests.structures import CaseInsensitiveDict
|
||||||
|
|
||||||
text_extractor_regexp_compile = re.compile(r".*\(.*\).*")
|
text_extractor_regexp_compile = re.compile(r".*\(.*\).*")
|
||||||
|
|
||||||
@@ -197,6 +197,9 @@ class ResponseObject(object):
|
|||||||
else:
|
else:
|
||||||
value = self._extract_field_with_delimiter(field)
|
value = self._extract_field_with_delimiter(field)
|
||||||
|
|
||||||
|
if is_py2 and isinstance(value, unicode):
|
||||||
|
value = value.encode("utf-8")
|
||||||
|
|
||||||
msg += "\t=> {}".format(value)
|
msg += "\t=> {}".format(value)
|
||||||
logger.log_debug(msg)
|
logger.log_debug(msg)
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
import requests
|
import requests
|
||||||
from httprunner import exceptions, response, utils
|
from httprunner import exceptions, response, utils
|
||||||
from httprunner.compat import bytes, str
|
from httprunner.compat import basestring, bytes
|
||||||
from tests.base import HTTPBIN_SERVER, ApiServerUnittest
|
from tests.base import HTTPBIN_SERVER, ApiServerUnittest
|
||||||
|
|
||||||
|
|
||||||
@@ -259,7 +259,7 @@ class TestResponse(ApiServerUnittest):
|
|||||||
]
|
]
|
||||||
extract_binds_dict = resp_obj.extract_response(extract_binds_list)
|
extract_binds_dict = resp_obj.extract_response(extract_binds_list)
|
||||||
|
|
||||||
self.assertIsInstance(extract_binds_dict["resp_content"], str)
|
self.assertIsInstance(extract_binds_dict["resp_content"], basestring)
|
||||||
self.assertIn("httpbin.org", extract_binds_dict["resp_content"])
|
self.assertIn("httpbin.org", extract_binds_dict["resp_content"])
|
||||||
|
|
||||||
extract_binds_list = [
|
extract_binds_list = [
|
||||||
|
|||||||
Reference in New Issue
Block a user