class ShorterOrEqual(OperatorTestCase): def test_length_value(self): ref = 12 self.assert_match([], ref) self.assert_match([1], ref) self.assert_match("Alice", ref) self.assert_match(range(ref), ref) self.assert_match('x' * ref, ref) self.assert_no_match('x' * (ref + 1), ref) self.assert_no_match("Alice has a cat", ref) def test_sequence(self): ref = [1, 2, 3] for s in self.subsets(ref): self.assert_match(list(s), ref) self.assert_match([42] * (len(ref) - 1), ref) self.assert_no_match(2 * ref, ref) test_repr = lambda self: self.assert_repr(__unit__.ShorterOrEqual(42)) # Assertion functions def assert_match(self, value, ref): return super(ShorterOrEqual, self) \ .assert_match(__unit__.ShorterOrEqual(ref), value) def assert_no_match(self, value, ref): return super(ShorterOrEqual, self) \ .assert_no_match(__unit__.ShorterOrEqual(ref), value)
def assert_no_match(self, value, ref): return super(ShorterOrEqual, self) \ .assert_no_match(__unit__.ShorterOrEqual(ref), value)