Commit f874f72c authored by Guilhem Saurel's avatar Guilhem Saurel Committed by GitHub

Merge pull request #37 from nim65s/devel

check signal types in dg.plug, fix #36
parents 4db30576 8ee7e435
Pipeline #7539 failed with stage
in 1 minute and 34 seconds
......@@ -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 {
......
# Test bindings
ADD_PYTHON_UNIT_TEST("test-bindings" "unitTesting/test_bindings.py" src)
# Test the interpreter
SET(EXECUTABLE_NAME interpreter-test)
......@@ -59,3 +57,6 @@ TARGET_LINK_LIBRARIES(${PYTHON_MODULE} ${PUBLIC_KEYWORD} ${LIBRARY_NAME} ${PYTHO
## Test it
ADD_PYTHON_UNIT_TEST("test-custom-entity" "unitTesting/test_custom_entity.py" src unitTesting)
# also test other bindings, using this custom entity
ADD_PYTHON_UNIT_TEST("test-bindings" "unitTesting/test_bindings.py" src unitTesting)
import unittest
import dynamic_graph
import dynamic_graph as dg
from custom_entity import CustomEntity
class BindingsTests(unittest.TestCase):
def test_bindings(self):
with self.assertRaises(Exception) as error:
dynamic_graph.error_out()
self.assertEqual(str(error), "something bad happend")
with self.assertRaises(Exception) as cm:
dg.error_out()
self.assertEqual(str(cm.exception), "something bad happened")
def test_type_check(self):
first = CustomEntity('first_entity')
second = CustomEntity('second_entity')
# Check that we can connect first.out to second.in
dg.plug(first.signal('out_double'), second.signal('in_double'))
# Check that we can't connect first.out to second
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