예제 #1
0
파일: __init__.py 프로젝트: zz38/marathon
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)
예제 #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)
예제 #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())
예제 #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")))
예제 #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")))
예제 #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"))
예제 #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")))
예제 #8
0
def has_str(matcher):
    return has_feature("str", str, matcher)