Matcher classes to be used inside of the testtools assertThat framework.
-
class DictKeysMismatch(d1only, d2only)
Bases: object
-
describe()
-
get_details()
-
class DictListMatches(l1, approx_equal=False, tolerance=0.001)
Bases: object
-
match(l2)
Assert a list of dicts are equivalent.
-
class DictMatches(d1, approx_equal=False, tolerance=0.001)
Bases: object
-
match(d2)
Assert two dicts are equivalent.
This is a ‘deep’ match in the sense that it handles nested
dictionaries appropriately.
NOTE:
If you don’t care (or don’t know) a given value, you can specify
the string DONTCARE as the value. This will cause that dict-item
to be skipped.
-
class DictMismatch(key, d1_value, d2_value)
Bases: object
-
describe()
-
get_details()
-
class FunctionCallMatcher(expected_func_calls)
Bases: object
-
call(*args, **kwargs)
-
match()
-
class IsSubDictOf(super_dict)
Bases: object
-
match(sub_dict)
Assert a sub_dict is subset of super_dict.
-
class ListLengthMismatch(len1, len2)
Bases: object
-
describe()
-
get_details()
-
class SubDictMismatch(key=None, sub_value=None, super_value=None, keys=False)
Bases: object
-
describe()
-
get_details()
-
class XMLAttrKeysMismatch(state, expected_only, actual_only)
Bases: nova.tests.matchers.XMLMismatch
XML attribute keys don’t match.
-
describe()
-
class XMLAttrValueMismatch(state, key, expected_value, actual_value)
Bases: nova.tests.matchers.XMLMismatch
XML attribute values don’t match.
-
describe()
-
class XMLExpectedChild(state, tag, idx)
Bases: nova.tests.matchers.XMLMismatch
Expected child not present in XML.
-
describe()
-
class XMLMatchState(expected, actual)
Bases: object
Maintain some state for matching.
Tracks the XML node path and saves the expected and actual full
XML text, for use by the XMLMismatch subclasses.
-
node(tag, idx)
Adds tag and index to the path; they will be popped off when
the corresponding ‘with’ statement exits.
Parameters: |
- tag – The element tag
- idx – If not None, the integer index of the element
within its parent. Not included in the path
element if None.
|
-
class XMLMatches(expected)
Bases: object
Compare XML strings. More complete than string comparison.
-
match(actual_xml)
-
class XMLMismatch(state)
Bases: object
Superclass for XML mismatch.
-
describe()
-
get_details()
-
class XMLTagMismatch(state, idx, expected_tag, actual_tag)
Bases: nova.tests.matchers.XMLMismatch
XML tags don’t match.
-
describe()
-
class XMLTextValueMismatch(state, expected_text, actual_text)
Bases: nova.tests.matchers.XMLMismatch
XML text values don’t match.
-
describe()
-
class XMLUnexpectedChild(state, tag, idx)
Bases: nova.tests.matchers.XMLMismatch
Unexpected child present in XML.
-
describe()