Exemple #1
0
    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))
Exemple #2
0
 def test_correct_iface(self):
     decorator = returns(SimpleInterface)
     decorator(function_returning_simpleclass)()
Exemple #3
0
 def test_any(self):
     decorator = returns(Any)
     for func in self._functions_for_tests():
         decorated = decorator(func)
         decorated()
Exemple #4
0
 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))
Exemple #5
0
 def test_non_function(self):
     decorator = returns(Any)
     self.assertRaises(TypeError, decorator, 1)