Skip to content
This repository was archived by the owner on Jun 5, 2020. It is now read-only.

Let _make_validate method supports the list structures JSON #18

Closed
wants to merge 1 commit into from
Closed

Let _make_validate method supports the list structures JSON #18

wants to merge 1 commit into from

Conversation

asdf2014
Copy link

No description provided.

@coveralls
Copy link

Coverage Status

Coverage increased (+2.5%) to 77.193% when pulling bfe6aa4 on asdf2014:validate_list into 623db1d on HttpRunner:master.

5 similar comments
@coveralls
Copy link

Coverage Status

Coverage increased (+2.5%) to 77.193% when pulling bfe6aa4 on asdf2014:validate_list into 623db1d on HttpRunner:master.

@coveralls
Copy link

Coverage Status

Coverage increased (+2.5%) to 77.193% when pulling bfe6aa4 on asdf2014:validate_list into 623db1d on HttpRunner:master.

@coveralls
Copy link

Coverage Status

Coverage increased (+2.5%) to 77.193% when pulling bfe6aa4 on asdf2014:validate_list into 623db1d on HttpRunner:master.

@coveralls
Copy link

Coverage Status

Coverage increased (+2.5%) to 77.193% when pulling bfe6aa4 on asdf2014:validate_list into 623db1d on HttpRunner:master.

@coveralls
Copy link

Coverage Status

Coverage increased (+2.5%) to 77.193% when pulling bfe6aa4 on asdf2014:validate_list into 623db1d on HttpRunner:master.

{"eq": ["content.{}".format(key), value]}
)
if isinstance(resp_content_json, dict):
for key, value in resp_content_json.items():
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if isinstance(value, (dict, list)):
    continue

这一部分还是有必要的,因为假如 value 为 dict/list,已经算是复杂结构体了,保持不变的可能性较小,所以不宜直接将其作为比较项。

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

的确,不过目前我这边用的还没有这个问题 😅

)
elif isinstance(resp_content_json, list):
for i in range(0, len(resp_content_json)):
resp_content_json = resp_content_json[i]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这里有两个问题:
1、重复使用 resp_content_json 这个变量名容易产生混淆,建议对 list 的元素采用不同的变量名;
2、你这里假设 list 始终是 [{a:a},{b:b},...] 的形式,那假如出现 [{a:a},b,...] 的情况就会出现问题。

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

是的,想要通用的话,还是要多考虑一下这块,期待后续 validator 支持 jmespath 的语法~~

@debugtalk
Copy link
Member

@asdf2014 我先将这个PR关闭了哈,后面会更新为 jmespath 语法。

@debugtalk debugtalk closed this Feb 3, 2019
@asdf2014 asdf2014 deleted the validate_list branch February 3, 2019 14:06
@asdf2014
Copy link
Author

asdf2014 commented Feb 3, 2019

@debugtalk 嗯呢,期待下

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants