lib.expectation

class dt4test.lib.expectation.Expectation[source]
Assertions
dictionaries_should_be_equal(dict1, dict2, msg=None, values=True)[source]

字典应该相等

dictionary_should_contain_item(dictionary, key, value, msg=None)[source]

字典应该包含元素

dictionary_should_contain_key(dictionary, key, msg=None)[source]

字典应该包含 key

dictionary_should_contain_value(dictionary, value, msg=None)[source]

字典应该包含值

dictionary_should_not_contain_key(dictionary, key, msg=None)[source]

字典不应该包含key

dictionary_should_not_contain_value(dictionary, value, msg=None)[source]

字典不应该包含值

directory_should_be_empty(path, msg=None)[source]

目录应该为空

directory_should_exist(path, msg=None)[source]

目录应该存在

directory_should_not_be_empty(path, msg=None)[source]

目录应该非空

directory_should_not_exist(path, msg=None)[source]

目录应该不存在

file_should_be_empty(path, msg=None)[source]

文件应该为空

file_should_exist(path, msg=None)[source]

文件应该存在

file_should_not_be_empty(path, msg=None)[source]

文件应该非空

file_should_not_exist(path, msg=None)[source]

文件应该不存在

length_should_be(item, length, msg=None)[source]

长度应该是

list_should_contain_sub_list(list1, list2, msg=None, values=True)[source]

列表应该包含子列表

list_should_contain_value(list_, value, msg=None)[source]

列表应该包含值

list_should_not_contain_duplicates(list_, msg=None)[source]

列表应该不包含重复的值

list_should_not_contain_value(list_, value, msg=None)[source]

列表应该不包含值

lists_should_be_equal(list1, list2, msg=None, values=True, names=None, ignore_order=False)[source]

列表应该相等

should_be_byte_string(item, msg=None)[source]

应该是字节串

should_be_empty(item, msg=None)[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_numbers(first, second, msg=None, values=True, precision=6)[source]

作为数值应该相等

should_be_equal_as_strings(first, second, msg=None, values=True, ignore_case=False, strip_spaces=False, formatter='str', collapse_spaces=False)[source]

作为字符串相等

should_be_lower_case(string, msg=None)[source]

应该全是小写

should_be_unicode_string(item, msg=None)[source]

应该是unicode串

should_be_upper_case(string, msg=None)[source]

应该全是大写

should_contain(container, item, msg=None, values=True, ignore_case=False, strip_spaces=False, collapse_spaces=False)[source]

Fails if container does not contain item one or more times.

should_contain_any(container, *items, **configuration)[source]

应该包含任意一个,Python in 操作

Supports additional configuration parameters msg, values, ignore_case and strip_spaces, and collapse_spaces which have exactly the same semantics as arguments with same names have with Should Contain. These arguments must always be given using name=value syntax after all items.

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_exist(path, msg=None)[source]

文件或目录应该存在

should_match(string, pattern, msg=None, values=True, ignore_case=False)[source]

Fails if the given string does not match the given pattern.

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 string does not match pattern as a regular expression.

Notice that the given pattern does not need to match the whole string. For example, the pattern ello matches the string Hello 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 string ello.

should_not_be_empty(item, msg=None)[source]

应该非空

should_not_be_equal_as_integers(first, second, msg=None, values=True, base=None)[source]

作为整数应该不相等

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 container does not contain item

should_not_contain_any(container, *items, **configuration)[source]

应该不包含任意一个,Python not in 操作

should_not_contain_match(list, pattern, msg=None, case_insensitive=False, whitespace_insensitive=False)[source]

列表不应该包含模式

should_not_exist(path, msg=None)[source]

文件或目录应该不存在

should_not_match(string, pattern, msg=None, values=True, ignore_case=False)[source]

应该不匹配模式

should_not_match_regexp(string, pattern, msg=None, values=True)[source]

应该不匹配正则