Commit 8ee7e435 authored by Guilhem Saurel's avatar Guilhem Saurel

check signal types in dg.plug

While here, develop test from previous commit, and fix another test in
the same file.

fix #36
parent 6e43bd1f
......@@ -40,8 +40,10 @@ PyObject* plug(PyObject* /*self*/, PyObject* args) {
pObjIn = PyCapsule_GetPointer(objIn, "dynamic_graph.Signal");
SignalBase<int>* signalIn = (SignalBase<int>*)pObjIn;
if (signalIn == NULL) return NULL;
pObjOut = PyCapsule_GetPointer(objOut, "dynamic_graph.Signal");
SignalBase<int>* signalOut = (SignalBase<int>*)pObjOut;
if (signalOut == NULL) return NULL;
std::ostringstream os;
try {
......@@ -6,9 +6,9 @@ from custom_entity import CustomEntity
class BindingsTests(unittest.TestCase):
def test_bindings(self):
with self.assertRaises(Exception) as error:
with self.assertRaises(Exception) as cm:
self.assertEqual(str(error), "something bad happend")
self.assertEqual(str(cm.exception), "something bad happened")
def test_type_check(self):
first = CustomEntity('first_entity')
......@@ -16,8 +16,9 @@ class BindingsTests(unittest.TestCase):
# Check that we can connect first.out to
dg.plug(first.signal('out_double'), second.signal('in_double'))
# Check that we can't connect first.out to second
with self.assertRaises(Exception):
with self.assertRaises(ValueError) as cm:
dg.plug(first.signal('out_double'), second)
self.assertEqual(str(cm.exception), "PyCapsule_GetPointer called with incorrect name")
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