Ejemplo n.º 1
0
 def test_runtime_error_on_add_with_different_args(self):
     adder = BuiltinsAdder()
     function = mock.Mock()
     adder.add_type("foo", function)
     adder.add("foo", dict(argument=1))
     try:
         adder.add("foo", dict(argument=2))
     except RuntimeError as exc:
         self.assertEqual(str(exc),
                          "Optional builtin %r added with arguments %r has already been added with arguments %r"
                          % ("foo", dict(argument=2), dict(argument=1)))
     else:
         self.fail("RuntimeError not raised")
Ejemplo n.º 2
0
 def test_runtime_error_on_add_with_different_args(self):
     adder = BuiltinsAdder()
     function = mock.Mock()
     adder.add_type("foo", function)
     adder.add("foo", dict(argument=1))
     try:
         adder.add("foo", dict(argument=2))
     except RuntimeError as exc:
         self.assertEqual(str(exc),
                          "Optional builtin %r added with arguments %r has already been added with arguments %r"
                          % ("foo", dict(argument=2), dict(argument=1)))
     else:
         self.fail("RuntimeError not raised")
Ejemplo n.º 3
0
 def test_adds_dependencies(self):
     adder = BuiltinsAdder()
     function1 = mock.Mock()
     function2 = mock.Mock()
     function3 = mock.Mock()
     function4 = mock.Mock()
     adder.add_type("foo1", function1)
     adder.add_type("foo2", function2, ["foo1"])
     adder.add_type("foo3", function3, ["foo2"])
     adder.add_type("foo4", function4)
     adder.add("foo3", dict(argument=1))
     adder.add("foo2")
     function1.assert_called_once_with()
     function2.assert_called_once_with()
     function3.assert_called_once_with(argument=1)
     self.assertFalse(function4.called)
Ejemplo n.º 4
0
 def test_adds_dependencies(self):
     adder = BuiltinsAdder()
     function1 = mock.Mock()
     function2 = mock.Mock()
     function3 = mock.Mock()
     function4 = mock.Mock()
     adder.add_type("foo1", function1)
     adder.add_type("foo2", function2, ["foo1"])
     adder.add_type("foo3", function3, ["foo2"])
     adder.add_type("foo4", function4)
     adder.add("foo3", dict(argument=1))
     adder.add("foo2")
     function1.assert_called_once_with()
     function2.assert_called_once_with()
     function3.assert_called_once_with(argument=1)
     self.assertFalse(function4.called)
Ejemplo n.º 5
0
 def test_add_type():
     adder = BuiltinsAdder()
     function = mock.Mock()
     adder.add_type("foo", function)
     adder.add("foo", dict(argument=1))
     function.assert_called_once_with(argument=1)
Ejemplo n.º 6
0
 def test_add_type():
     adder = BuiltinsAdder()
     function = mock.Mock()
     adder.add_type("foo", function)
     adder.add("foo", dict(argument=1))
     function.assert_called_once_with(argument=1)