Asserts that actual value satisfies matcher. (Can also assert plain boolean condition.)
Parameters: |
|
---|
assert_that passes the actual value to the matcher for evaluation. If the matcher is not satisfied, an exception is thrown describing the mismatch.
assert_that is designed to integrate well with PyUnit and other unit testing frameworks. The exception raised for an unmet assertion is an AssertionError, which PyUnit reports as a test failure.
With a different set of parameters, assert_that can also verify a boolean condition:
Parameters: |
|
---|
This is equivalent to the assertTrue method of unittest.TestCase, but offers greater flexibility in test writing by being a standalone function.
Wraps a matcher to define equality in terms of satisfying the matcher.
match_equality allows Hamcrest matchers to be used in libraries that are not Hamcrest-aware. They might use the equality operator:
assert match_equality(matcher) == object
Or they might provide a method that uses equality for its test:
library.method_that_tests_eq(match_equality(matcher))
One concrete example is integrating with the assert_called_with methods in Michael Foord’s mock library.