コード例 #1
0
    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())
コード例 #2
0
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))
コード例 #3
0
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))
コード例 #4
0
    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())
コード例 #5
0
 def testProvidesConvenientShortcutForMatchingWithEqualTo(self):
     self.assert_matches(
         "Values automatically wrapped with equal_to",
         only_contains(less_than(3), 7),
         self._sequence(0, 7, 1, 2),
     )
コード例 #6
0
 def testMatchesAllItemsWithOneMatcher(self):
     self.assert_matches("one matcher", only_contains(less_than(3)),
                         self._sequence(0, 1, 2))
コード例 #7
0
 def testMatchesAllItemsWithMultipleMatchers(self):
     self.assert_matches(
         "multiple matchers",
         only_contains(less_than(3), equal_to(7)),
         self._sequence(0, 7, 1, 2),
     )
コード例 #8
0
 def testProvidesConvenientShortcutForMatchingWithEqualTo(self):
     self.assert_matches('Values automatically wrapped with equal_to',
                         only_contains(less_than(3), 7),
                         self._sequence(0, 7, 1, 2))
コード例 #9
0
 def testDoesNotMatchListWithMismatchingItem(self):
     self.assert_does_not_match('3 is not less than 3',
                                only_contains(less_than(3)), self._sequence(1, 2, 3))
コード例 #10
0
 def testComparesObjectsForLessThan(self):
     self.assert_matches("match", less_than(1), 0)
     self.assert_does_not_match("no match", less_than(1), 1)
コード例 #11
0
 def testMatchesAllItemsWithMultipleMatchers(self):
     self.assert_matches('multiple matchers',
                         only_contains(less_than(3), equal_to(7)),
                         self._sequence(0, 7, 1, 2))
コード例 #12
0
 def testMatchesAllItemsWithMultipleMatchers(self):
     self.assert_matches('multiple matchers',
                         only_contains(less_than(3), equal_to(7)),
                         [0, 7, 1, 2])
コード例 #13
0
 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))
コード例 #14
0
 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)
コード例 #15
0
 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)
コード例 #16
0
 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)
コード例 #17
0
 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))
コード例 #18
0
 def testSupportsDifferentTypesOfComparableObjects(self):
     self.assert_matches("strings", greater_than("bb"), "cc")
     self.assert_matches("dates", less_than(date.today()), date.min)
コード例 #19
0
 def testDoesNotMatchListWithMismatchingItem(self):
     self.assert_does_not_match("3 is not less than 3",
                                only_contains(less_than(3)),
                                self._sequence(1, 2, 3))
コード例 #20
0
 def testMatchesAllItemsWithOneMatcher(self):
     self.assert_matches('one matcher',
                         only_contains(less_than(3)), self._sequence(0, 1, 2))
コード例 #21
0
 def testMatchesAllItemsWithOneMatcher(self):
     self.assert_matches('one matcher', only_contains(less_than(3)),
                         [0, 1, 2])
コード例 #22
0
 def testDoesNotMatchListWithMismatchingItem(self):
     self.assert_does_not_match('3 is not less than 3',
                                only_contains(less_than(3)), [1, 2, 3])