bugfix #34: handle exception when response content is empty

This commit is contained in:
httprunner
2017-08-29 14:44:44 +08:00
parent 969c3cce78
commit 1080d620bd
6 changed files with 58 additions and 10 deletions

View File

@@ -31,10 +31,13 @@ class ResponseObject(object):
"content.person.name.first_name"
"""
try:
field += "."
# string.split(sep=None, maxsplit=-1) -> list of strings
# e.g. "content.person.name" => ["content", "person.name"]
top_query, sub_query = field.split(delimiter, 1)
try:
top_query, sub_query = field.split(delimiter, 1)
except ValueError:
top_query = field
sub_query = None
if top_query in ["body", "content", "text"]:
json_content = self.parsed_body()