def test_function_with_keyword_args(self): decorator = expects(Any, Any, foo = SimpleInterface) decorated = decorator(keyword_function) decorated(0, 1, foo = SimpleClass()) self.assertRaises(TypeError, decorated, 0, 1, foo = 2)
def test_keyword_spec_but_normal_call(self): decorator = expects(Any, second = SimpleInterface) decorated = decorator(normal_function) decorated(1, SimpleClass())
def test_function_with_variadic_args(self): decorator = expects(Any, SimpleInterface) decorated = decorator(variadic_function) decorated(1, SimpleClass()) self.assertRaises(TypeError, decorated, 0, 1)
def test_keyword_args(self): decorator = expects(first = SimpleInterface, second = SimpleInterface) decorated = decorator(normal_function) decorated(first = SimpleClass(), second = SimpleClass())
def test_normal_spec_but_keyword_call(self): decorator = expects(SimpleInterface, Any) decorated = decorator(normal_function) decorated(first = SimpleClass(), second = "")
def test_incorrect_iface_arg(self): decorator = expects(SimpleInterface, Any) decorated = decorator(normal_function) self.assertRaises(TypeError, decorated, (1, 0))
def test_correct_iface_arg(self): decorator = expects(SimpleInterface, Any) decorated = decorator(normal_function) decorated(SimpleClass(), 1)
def test_too_short_argspec(self): decorator = expects(Any) self.assertRaises(TypeError, decorator, normal_function)
def test_any(self): decorator = expects(Any, Any) decorated = decorator(normal_function) decorated(1, [{'foo':42}])
def test_non_function(self): decorator = expects(Any) self.assertRaises(TypeError, decorator, 1)