Esempio n. 1
0
def has_len(matcher):
    """Match len of a value.

    assert_that([1, 2], has_len(2)) will pass but assert_that([1, 2], has_len(1))
    will fail with an assertion error.
    """
    return has_feature("len", len, matcher)
Esempio n. 2
0
def has_len(matcher):
    """Match len of a value.

    assert_that([1, 2], has_len(2)) will pass but assert_that([1, 2], has_len(1))
    will fail with an assertion error.
    """
    return has_feature("len", len, matcher)
Esempio n. 3
0
def description_contains_description_of_property():
    matcher = has_feature("name", lambda user: user.username, equal_to("bob"))
    assert_equal("name: 'bob'", matcher.describe())
Esempio n. 4
0
def submatcher_is_coerced_to_matcher():
    matcher = has_feature("name", lambda user: user.username, "bob")
    assert_equal(unmatched("name: was 'bobbity'"),
                 matcher.match(User("bobbity")))
Esempio n. 5
0
def explanation_of_mismatch_contains_mismatch_of_feature():
    matcher = has_feature("name", lambda user: user.username, equal_to("bob"))
    assert_equal(unmatched("name: was 'bobbity'"),
                 matcher.match(User("bobbity")))
Esempio n. 6
0
def mismatches_when_feature_extraction_fails():
    # TODO:
    return
    matcher = has_feature("name", lambda user: user.username, equal_to("bob"))
    assert_equal(unmatched(""), matcher.match("bobbity"))
Esempio n. 7
0
def matches_when_feature_has_correct_value():
    matcher = has_feature("name", lambda user: user.username, equal_to("bob"))
    assert_equal(matched(), matcher.match(User("bob")))
Esempio n. 8
0
def has_str(matcher):
    return has_feature("str", str, matcher)