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", "*****@*****.**")))
Esempio n. 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())
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()
    )
def description_contains_description_of_property():
    assert_equal(
        "object with attribute username: '******'",
        has_attr("username", equal_to("bob")).describe()
    )
def submatcher_is_coerced_to_matcher():
    assert_equal(
        unmatched("attribute username was 'bobbity'"),
        has_attr("username", "bob").match(User("bobbity"))
    )
def explanation_of_mismatch_contains_mismatch_of_property():
    assert_equal(
        unmatched("attribute username was 'bobbity'"),
        has_attr("username", equal_to("bob")).match(User("bobbity"))
    )
def mismatches_when_property_is_missing():
    assert_equal(
        unmatched("was missing attribute username"),
        has_attr("username", equal_to("bob")).match("bobbity")
    )
def matches_when_property_has_correct_value():
    assert_equal(matched(), has_attr("username", equal_to("bob")).match(User("bob")))
def description_contains_description_of_property():
    assert_equal("object with attribute username: '******'",
                 has_attr("username", equal_to("bob")).describe())
def submatcher_is_coerced_to_matcher():
    assert_equal(unmatched("attribute username was 'bobbity'"),
                 has_attr("username", "bob").match(User("bobbity")))
def explanation_of_mismatch_contains_mismatch_of_property():
    assert_equal(unmatched("attribute username was 'bobbity'"),
                 has_attr("username", equal_to("bob")).match(User("bobbity")))
def mismatches_when_property_is_missing():
    assert_equal(unmatched("was missing attribute username"),
                 has_attr("username", equal_to("bob")).match("bobbity"))
def matches_when_property_has_correct_value():
    assert_equal(matched(),
                 has_attr("username", equal_to("bob")).match(User("bob")))
Esempio n. 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"))