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", "*****@*****.**")))
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 matches_when_any_submatchers_match(): matcher = any_of( equal_to("bob"), equal_to("jim"), ) assert_equal( matched(), matcher.match("bob"), )
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 mismatches_when_no_submatchers_match(): matcher = any_of( equal_to("bob"), equal_to("jim"), ) assert_equal( unmatched("did not match any of:\n * 'bob' [was 'alice']\n * 'jim' [was 'alice']"), matcher.match("alice"), )
def mismatches_when_no_submatchers_match(): matcher = any_of( equal_to("bob"), equal_to("jim"), ) assert_equal( unmatched( "did not match any of:\n * 'bob' [was 'alice']\n * 'jim' [was 'alice']" ), matcher.match("alice"), )