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