mirror of
https://github.com/httprunner/httprunner.git
synced 2026-05-17 05:57:37 +08:00
#29: refactor validator:
1, relocate validate functions; 2, add unittest for custom defined validators.
This commit is contained in:
@@ -30,3 +30,13 @@ get_sign_lambda = lambda *args: hmac.new(
|
||||
|
||||
def gen_md5(*args):
|
||||
return hashlib.md5("".join(args).encode('utf-8')).hexdigest()
|
||||
|
||||
def sum_status_code(status_code, expect_sum):
|
||||
""" sum status code digits
|
||||
e.g. 400 => 4, 201 => 3
|
||||
"""
|
||||
sum_value = 0
|
||||
for digit in str(status_code):
|
||||
sum_value += int(digit)
|
||||
|
||||
assert sum_value == expect_sum
|
||||
|
||||
Reference in New Issue
Block a user