Commit 1c9e8d88 authored by Guilhem Saurel's avatar Guilhem Saurel

more explicit error message for dgpy.plug argument issues

thanks @jviereck
parent 834ff2f5
......@@ -49,7 +49,8 @@ PyObject* plug(
if (signalIn == NULL) {
struct module_state* st = GETSTATE(m);
std::ostringstream oss;
oss << "dgpy.plug in argument must be a dynamic_graph.Signal, not a " << PyCapsule_GetName(objIn);
oss << "dynamic_graph.plug(a, b): Argument 'b' must be of type 'dynamic_graph.Signal', but got "
<< PyCapsule_GetName(objIn);
PyErr_SetString(st->dgpyError, oss.str().c_str());
return NULL;
}
......@@ -58,7 +59,8 @@ PyObject* plug(
if (signalOut == NULL) {
struct module_state* st = GETSTATE(m);
std::ostringstream oss;
oss << "dgpy.plug out argument must be a dynamic_graph.Signal, not a " << PyCapsule_GetName(objOut);
oss << "dynamic_graph.plug(a, b): Argument 'a' must be of type 'dynamic_graph.Signal', but got "
<< PyCapsule_GetName(objOut);
PyErr_SetString(st->dgpyError, oss.str().c_str());
return NULL;
}
......
......@@ -4,6 +4,8 @@ import dynamic_graph as dg
from custom_entity import CustomEntity
ERR = "dynamic_graph.plug(a, b): Argument '%s' must be of type 'dynamic_graph.Signal', but got dynamic_graph.Entity"
class BindingsTests(unittest.TestCase):
def test_bindings(self):
......@@ -20,14 +22,12 @@ class BindingsTests(unittest.TestCase):
# Check that we can't connect first.out to second
with self.assertRaises(dg.dgpyError) as cm_in:
dg.plug(first.signal('out_double'), second)
self.assertEqual(str(cm_in.exception),
"dgpy.plug in argument must be a dynamic_graph.Signal, not a dynamic_graph.Entity")
self.assertEqual(str(cm_in.exception), ERR % 'b')
# Check that we can't connect first to second.in
with self.assertRaises(dg.dgpyError) as cm_out:
dg.plug(first, second.signal('in_double'))
self.assertEqual(str(cm_out.exception),
"dgpy.plug out argument must be a dynamic_graph.Signal, not a dynamic_graph.Entity")
self.assertEqual(str(cm_out.exception), ERR % 'a')
if __name__ == '__main__':
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment