def test_all_of_describes_first_failing_match_if_match_fails(): class Rectangle(object): pass expected_output = [] is_a(Rectangle).matches("Rectangle", expected_output) mismatch_output = [] matcher = all_of(any_value(), is_a(Rectangle), has_attr(width=20)) matcher.matches("Rectangle", mismatch_output) assert_equals(expected_output, mismatch_output)
def test_any_value_does_not_write_to_mismatch_output(): mismatch_output = [] any_value().matches("foo", mismatch_output) any_value().matches(1, mismatch_output) any_value().matches(type, mismatch_output) assert not mismatch_output
def test_any_value_str(): assert_equals(str(any_value()), "<any value>")
def test_any_value_matches_everything(): assert any_value().matches("foo", []) assert any_value().matches(1, []) assert any_value().matches(type, [])