mirror of
https://github.com/httprunner/httprunner.git
synced 2026-05-31 05:19:38 +08:00
bug fix: 当使用.csv文件内容来做数据驱动测试时, length_xxx函数都会失败
This commit is contained in:
@@ -37,27 +37,32 @@ def string_equals(check_value, expect_value):
|
||||
|
||||
def length_equals(check_value, expect_value):
|
||||
assert isinstance(expect_value, integer_types)
|
||||
assert len(check_value) == expect_value
|
||||
expect_len = _cast_to_int(expect_value)
|
||||
assert len(check_value) == expect_len
|
||||
|
||||
|
||||
def length_greater_than(check_value, expect_value):
|
||||
assert isinstance(expect_value, integer_types)
|
||||
assert len(check_value) > expect_value
|
||||
expect_len = _cast_to_int(expect_value)
|
||||
assert len(check_value) > expect_len
|
||||
|
||||
|
||||
def length_greater_than_or_equals(check_value, expect_value):
|
||||
assert isinstance(expect_value, integer_types)
|
||||
assert len(check_value) >= expect_value
|
||||
expect_len = _cast_to_int(expect_value)
|
||||
assert len(check_value) >= expect_len
|
||||
|
||||
|
||||
def length_less_than(check_value, expect_value):
|
||||
assert isinstance(expect_value, integer_types)
|
||||
assert len(check_value) < expect_value
|
||||
expect_len = _cast_to_int(expect_value)
|
||||
assert len(check_value) < expect_len
|
||||
|
||||
|
||||
def length_less_than_or_equals(check_value, expect_value):
|
||||
assert isinstance(expect_value, integer_types)
|
||||
assert len(check_value) <= expect_value
|
||||
expect_len = _cast_to_int(expect_value)
|
||||
assert len(check_value) <= expect_len
|
||||
|
||||
|
||||
def contains(check_value, expect_value):
|
||||
@@ -97,3 +102,10 @@ def startswith(check_value, expect_value):
|
||||
|
||||
def endswith(check_value, expect_value):
|
||||
assert builtin_str(check_value).endswith(builtin_str(expect_value))
|
||||
|
||||
|
||||
def _cast_to_int(expect_value):
|
||||
try:
|
||||
return int(expect_value)
|
||||
except Exception:
|
||||
raise AssertionError("%r can't cast to int" % str(expect_value))
|
||||
Reference in New Issue
Block a user