def testMatchesAnyConformingSequence(self): class ObjectWithLenOnly: def __len__(self): return 20 self.assert_matches("quasi-sequence", only_contains(less_than(3)), QuasiSequence()) self.assert_does_not_match("non-sequence", only_contains(1), object()) self.assert_does_not_match("non-sequence with length", only_contains(1), ObjectWithLenOnly())
def step(context, range_operation): # get the range text from below the slider handle range_text = context.rate_checker.get_credit_score_range() currentRange = int(range_text[:3]) if (range_operation == "increase"): assert_that(currentRange, greater_than(DEFAULT_CREDIT_SCORE)) elif (range_operation == "decrease"): assert_that(currentRange, less_than(DEFAULT_CREDIT_SCORE))
def testMatchesAnyConformingSequence(self): class ObjectWithLenOnly(object): def __len__(self): return 20 self.assert_matches("quasi-sequence", only_contains(less_than(3)), QuasiSequence()) self.assert_does_not_match("non-sequence", only_contains(1), object()) self.assert_does_not_match("non-sequence with length", only_contains(1), ObjectWithLenOnly())
def testProvidesConvenientShortcutForMatchingWithEqualTo(self): self.assert_matches( "Values automatically wrapped with equal_to", only_contains(less_than(3), 7), self._sequence(0, 7, 1, 2), )
def testMatchesAllItemsWithOneMatcher(self): self.assert_matches("one matcher", only_contains(less_than(3)), self._sequence(0, 1, 2))
def testMatchesAllItemsWithMultipleMatchers(self): self.assert_matches( "multiple matchers", only_contains(less_than(3), equal_to(7)), self._sequence(0, 7, 1, 2), )
def testProvidesConvenientShortcutForMatchingWithEqualTo(self): self.assert_matches('Values automatically wrapped with equal_to', only_contains(less_than(3), 7), self._sequence(0, 7, 1, 2))
def testDoesNotMatchListWithMismatchingItem(self): self.assert_does_not_match('3 is not less than 3', only_contains(less_than(3)), self._sequence(1, 2, 3))
def testComparesObjectsForLessThan(self): self.assert_matches("match", less_than(1), 0) self.assert_does_not_match("no match", less_than(1), 1)
def testMatchesAllItemsWithMultipleMatchers(self): self.assert_matches('multiple matchers', only_contains(less_than(3), equal_to(7)), self._sequence(0, 7, 1, 2))
def testMatchesAllItemsWithMultipleMatchers(self): self.assert_matches('multiple matchers', only_contains(less_than(3), equal_to(7)), [0, 7, 1, 2])
def test_search_limit(self): search = self.repository.list(size=1) self._assert_valid_search_list_result(search, 1) assert_that(len(search.results), less_than(search.total))
def testMismatchDescription(self): self.assert_mismatch_description("was <0>", greater_than(1), 0) self.assert_mismatch_description("was <2>", less_than(1), 2) self.assert_mismatch_description("was <0>", greater_than_or_equal_to(1), 0) self.assert_mismatch_description("was <2>", less_than_or_equal_to(1), 2)
def testDescribeMismatch(self): self.assert_describe_mismatch("was <0>", greater_than(1), 0) self.assert_describe_mismatch("was <2>", less_than(1), 2) self.assert_describe_mismatch("was <0>", greater_than_or_equal_to(1), 0) self.assert_describe_mismatch("was <2>", less_than_or_equal_to(1), 2)
def testSuccessfulMatchDoesNotGenerateMismatchDescription(self): self.assert_no_mismatch_description(greater_than(1), 2) self.assert_no_mismatch_description(less_than(1), 0) self.assert_no_mismatch_description(greater_than_or_equal_to(1), 1) self.assert_no_mismatch_description(less_than_or_equal_to(1), 1)
def testHasAReadableDescription(self): self.assert_description("a value greater than <1>", greater_than(1)) self.assert_description("a value greater than or equal to <1>", greater_than_or_equal_to(1)) self.assert_description("a value less than <1>", less_than(1)) self.assert_description("a value less than or equal to <1>", less_than_or_equal_to(1))
def testSupportsDifferentTypesOfComparableObjects(self): self.assert_matches("strings", greater_than("bb"), "cc") self.assert_matches("dates", less_than(date.today()), date.min)
def testDoesNotMatchListWithMismatchingItem(self): self.assert_does_not_match("3 is not less than 3", only_contains(less_than(3)), self._sequence(1, 2, 3))
def testMatchesAllItemsWithOneMatcher(self): self.assert_matches('one matcher', only_contains(less_than(3)), self._sequence(0, 1, 2))
def testMatchesAllItemsWithOneMatcher(self): self.assert_matches('one matcher', only_contains(less_than(3)), [0, 1, 2])
def testDoesNotMatchListWithMismatchingItem(self): self.assert_does_not_match('3 is not less than 3', only_contains(less_than(3)), [1, 2, 3])