def test_find_all(self, profile_dao_find_all): profile1 = CtiProfile() profile2 = CtiProfile() profile_dao_find_all.return_value = [profile1, profile2] [res1, res2] = services.find_all() assert_that(res1, same_instance(profile1)) assert_that(res2, same_instance(profile2))
def testMismatchDescriptionShowsActualArgumentAddress(self): matcher = same_instance("foo") description = StringDescription() expected = re.compile("was " + ADDRESS_FORMAT + " 'hi'") result = matcher.matches("hi", description) self.assertFalse(result, "Precondition: Matcher should not match item") self.assertTrue(expected.match(str(description)))
def test_get(self, profile_dao_get): profile = CtiProfile() profile_dao_get.return_value = profile result = services.get(1) assert_that(result, same_instance(profile)) profile_dao_get.assert_called_with(1)
def testDescribeMismatch(self): matcher = same_instance("foo") description = StringDescription() expected = re.compile("was " + ADDRESS_FORMAT + " 'hi'") matcher.describe_mismatch("hi", description) expected = re.compile("was " + ADDRESS_FORMAT + " 'hi'") self.assertTrue( expected.match(str(description)), "Expected %s to match %s" % (str(matcher), str(description)), )
def testDescribeMismatchWithNilShouldNotIncludeAddress(self): self.assert_describe_mismatch("was <None>", same_instance("foo"), None)
def testMismatchDescriptionWithNilShouldNotIncludeAddress(self): self.assert_mismatch_description("was <None>", same_instance("foo"), None)
def testSuccessfulMatchDoesNotGenerateMismatchDescription(self): o1 = object() self.assert_no_mismatch_description(same_instance(o1), o1)
def testDescriptionIncludesMemoryAddress(self): description = StringDescription() expected = re.compile("same instance as " + ADDRESS_FORMAT + " 'abc'") description.append_description_of(same_instance("abc")) self.assertTrue(expected.match(str(description)))
def testEvaluatesToTrueIfArgumentIsReferenceToASpecifiedObject(self): o1 = object() o2 = object() self.assert_matches("same", same_instance(o1), o1) self.assert_does_not_match("different", same_instance(o1), o2)