Пример #1
0
def matches_when_submatchers_all_match():
    matcher = any_of(
        has_attr("username", equal_to("bob")),
        has_attr("email_address", equal_to("*****@*****.**")),
    )
    
    assert_equal(matched(), matcher.match(User("bob", "*****@*****.**")))
Пример #2
0
def description_contains_descriptions_of_submatchers():
    matcher = any_of(
        has_attr("username", equal_to("bob")),
        has_attr("email_address", equal_to("*****@*****.**")),
    )

    assert_equal(
        "any of:\n  * object with attribute username: '******'\n  * object with attribute email_address: '*****@*****.**'",
        matcher.describe())
Пример #3
0
def description_contains_descriptions_of_submatchers():
    matcher = any_of(
        has_attr("username", equal_to("bob")),
        has_attr("email_address", equal_to("*****@*****.**")),
    )
    
    assert_equal(
        "any of:\n * object with attribute username: '******'\n * object with attribute email_address: '*****@*****.**'",
        matcher.describe()
    )
Пример #4
0
def description_contains_description_of_property():
    assert_equal(
        "object with attribute username: '******'",
        has_attr("username", equal_to("bob")).describe()
    )
Пример #5
0
def submatcher_is_coerced_to_matcher():
    assert_equal(
        unmatched("attribute username was 'bobbity'"),
        has_attr("username", "bob").match(User("bobbity"))
    )
Пример #6
0
def explanation_of_mismatch_contains_mismatch_of_property():
    assert_equal(
        unmatched("attribute username was 'bobbity'"),
        has_attr("username", equal_to("bob")).match(User("bobbity"))
    )
Пример #7
0
def mismatches_when_property_is_missing():
    assert_equal(
        unmatched("was missing attribute username"),
        has_attr("username", equal_to("bob")).match("bobbity")
    )
Пример #8
0
def matches_when_property_has_correct_value():
    assert_equal(matched(), has_attr("username", equal_to("bob")).match(User("bob")))
Пример #9
0
def description_contains_description_of_property():
    assert_equal("object with attribute username: '******'",
                 has_attr("username", equal_to("bob")).describe())
Пример #10
0
def submatcher_is_coerced_to_matcher():
    assert_equal(unmatched("attribute username was 'bobbity'"),
                 has_attr("username", "bob").match(User("bobbity")))
Пример #11
0
def explanation_of_mismatch_contains_mismatch_of_property():
    assert_equal(unmatched("attribute username was 'bobbity'"),
                 has_attr("username", equal_to("bob")).match(User("bobbity")))
Пример #12
0
def mismatches_when_property_is_missing():
    assert_equal(unmatched("was missing attribute username"),
                 has_attr("username", equal_to("bob")).match("bobbity"))
Пример #13
0
def matches_when_property_has_correct_value():
    assert_equal(matched(),
                 has_attr("username", equal_to("bob")).match(User("bob")))
Пример #14
0
def test_client_can_be_created():
    client = SpellClient(spell_conn_id="testing-spell-client")
    assert_that(client, has_attr("spell_conn_id", "testing-spell-client"))