lib.expectation
- class dt4test.lib.expectation.Expectation[source]
- Assertions
- lists_should_be_equal(list1, list2, msg=None, values=True, names=None, ignore_order=False)[source]
列表应该相等
- should_be_equal_as_integers(first, second, msg=None, values=True, base=None)[source]
作为整数相等
Examples :should_be_equal_as_integers(‘42’,42,’Error message’)should_be_equal_as_integers(‘ABCD’,’abcd’,base=16)should_be_equal_as_integers(‘0b1011’,’11’)
- should_be_equal_as_strings(first, second, msg=None, values=True, ignore_case=False, strip_spaces=False, formatter='str', collapse_spaces=False)[source]
作为字符串相等
- should_contain(container, item, msg=None, values=True, ignore_case=False, strip_spaces=False, collapse_spaces=False)[source]
Fails if
containerdoes not containitemone or more times.
- should_contain_any(container, *items, **configuration)[source]
应该包含任意一个,Python
in操作Supports additional configuration parameters
msg,values,ignore_caseandstrip_spaces, andcollapse_spaceswhich have exactly the same semantics as arguments with same names have with Should Contain. These arguments must always be given usingname=valuesyntax after allitems.Examples :should_contain_any( alist, item1, item2, item3)should_contain_any( alist, item1, item2, item3, ignore_case=True)
- should_contain_match(list, pattern, msg=None, case_insensitive=False, whitespace_insensitive=False)[source]
列表应该包含模式
- should_contain_x_times(container, item, count, msg=None, ignore_case=False, strip_spaces=False, collapse_spaces=False)[source]
应该包含 X 次
- should_match(string, pattern, msg=None, values=True, ignore_case=False)[source]
Fails if the given
stringdoes not match the givenpattern.Pattern matching is similar as matching files in a shell with
*,?and[chars]acting as wildcards.
- should_match_regexp(string, pattern, msg=None, values=True)[source]
Fails if
stringdoes not matchpatternas a regular expression.Notice that the given pattern does not need to match the whole string. For example, the pattern
ellomatches the stringHello world!. If a full match is needed, the^and$characters can be used to denote the beginning and end of the string, respectively. For example,^ello$only matches the exact stringello.
- should_not_be_equal_as_numbers(first, second, msg=None, values=True, precision=6)[source]
作为数值应该不相等
- should_not_be_equal_as_strings(first, second, msg=None, values=True, ignore_case=False, strip_spaces=False, collapse_spaces=False)[source]
作为字符串不相等
- should_not_contain(container, item, msg=None, values=True, ignore_case=False, strip_spaces=False, collapse_spaces=False)[source]
The
containerdoes not containitem