def test_incorrect_iface(self): decorator = returns(SimpleInterface) class OtherClass(object): def method(self, a, b): pass func = lambda: OtherClass() self.assertRaises(TypeError, decorator(func))
def test_correct_iface(self): decorator = returns(SimpleInterface) decorator(function_returning_simpleclass)()
def test_any(self): decorator = returns(Any) for func in self._functions_for_tests(): decorated = decorator(func) decorated()
def test_string(self): decorator = returns(str) decorator(function_returning_string)() self.assertRaises(TypeError, decorator(function_returning_None)) self.assertRaises(TypeError, decorator(function_returning_int)) self.assertRaises(TypeError, decorator(function_returning_simpleclass))
def test_non_function(self): decorator = returns(Any) self.assertRaises(TypeError, decorator, 1)