class Callable(MatcherTestCase): test_none = lambda self: self.assert_no_match(None) test_zero = lambda self: self.assert_no_match(0) test_string = lambda self: self.assert_no_match("Alice has a cat") test_some_object = lambda self: self.assert_no_match(object()) def test_function(self): def func(): pass self.assert_match(func) test_method = lambda self: self.assert_match(str.upper) test_type = lambda self: self.assert_match(object) def test_callable_object(self): class Foo(object): def __call__(self): pass self.assert_match(Foo()) def test_generator_function(self): def func(): yield self.assert_match(func) self.assert_no_match(func()) test_lambda = lambda self: self.assert_match(lambda: ()) test_generator = lambda self: self.assert_no_match(x for x in ()) test_repr = lambda self: self.assert_repr(__unit__.Callable()) # Assertion functions def assert_match(self, value): return super(Callable, self).assert_match(__unit__.Callable(), value) def assert_no_match(self, value): return super(Callable, self) \ .assert_no_match(__unit__.Callable(), value)
def assert_no_match(self, value): return super(Callable, self) \ .assert_no_match(__unit__.Callable(), value)