Beispiel #1
0
class Less(OperatorTestCase):
    def test_numbers(self):
        ref = 42

        self.assert_match(0, ref)
        self.assert_match(-ref, ref)
        self.assert_match(3.14, ref)

        self.assert_no_match(ref, ref)
        self.assert_no_match(2 * ref, ref)

    def test_strings(self):
        ref = "Alice has a cat"

        for i in range(len(ref) - 1):
            self.assert_match(ref[:i], ref)

        self.assert_no_match(ref, ref)
        self.assert_no_match(2 * ref, ref)
        self.assert_no_match("Bob has a cat", ref)

    def test_sets(self):
        ref = set([1, 2, 3, 5])

        for s in self.subsets(ref, strict=True):
            self.assert_match(s, ref)

        self.assert_no_match(ref, ref)
        self.assert_no_match(ref | set([7]), ref)
        self.assert_no_match(set([0]), ref)

    test_repr = lambda self: self.assert_repr(__unit__.Less(42))

    # Assertion functions

    def assert_match(self, value, ref):
        return super(Less, self).assert_match(__unit__.Less(ref), value)

    def assert_no_match(self, value, ref):
        return super(Less, self).assert_no_match(__unit__.Less(ref), value)
Beispiel #2
0
 def assert_no_match(self, value, ref):
     return super(Less, self).assert_no_match(__unit__.Less(ref), value)