Example #1
0
 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)
Example #2
0
 def test_keyword_spec_but_normal_call(self):
     decorator = expects(Any, second = SimpleInterface)
     decorated = decorator(normal_function)
     decorated(1, SimpleClass())
Example #3
0
 def test_function_with_variadic_args(self):
     decorator = expects(Any, SimpleInterface)
     decorated = decorator(variadic_function)
     decorated(1, SimpleClass())
     self.assertRaises(TypeError, decorated, 0, 1)
Example #4
0
 def test_keyword_args(self):
     decorator = expects(first = SimpleInterface, second = SimpleInterface)
     decorated = decorator(normal_function)
     decorated(first = SimpleClass(), second = SimpleClass())
Example #5
0
 def test_normal_spec_but_keyword_call(self):
     decorator = expects(SimpleInterface, Any)
     decorated = decorator(normal_function)
     decorated(first = SimpleClass(), second = "")
Example #6
0
 def test_incorrect_iface_arg(self):
     decorator = expects(SimpleInterface, Any)
     decorated = decorator(normal_function)
     self.assertRaises(TypeError, decorated, (1, 0))
Example #7
0
 def test_correct_iface_arg(self):
     decorator = expects(SimpleInterface, Any)
     decorated = decorator(normal_function)
     decorated(SimpleClass(), 1)
Example #8
0
 def test_too_short_argspec(self):
     decorator = expects(Any)
     self.assertRaises(TypeError, decorator, normal_function)
Example #9
0
 def test_any(self):
     decorator = expects(Any, Any)
     decorated = decorator(normal_function)
     decorated(1, [{'foo':42}])
Example #10
0
 def test_non_function(self):
     decorator = expects(Any)
     self.assertRaises(TypeError, decorator, 1)