From 6e43bd1f9deaa100416f8d13e870d4f225e2a4b9 Mon Sep 17 00:00:00 2001 From: Guilhem Saurel <guilhem.saurel@laas.fr> Date: Thu, 28 Nov 2019 15:16:36 +0100 Subject: [PATCH] [Tests] checks that connecting a signal to an entity raises an exception For now, this test doesn't pass, as an exception is not properly fired, but we get a segfault instead. --- unitTesting/CMakeLists.txt | 5 +++-- unitTesting/test_bindings.py | 14 ++++++++++++-- 2 files changed, 15 insertions(+), 4 deletions(-) diff --git a/unitTesting/CMakeLists.txt b/unitTesting/CMakeLists.txt index 9b79368..a8a5190 100644 --- a/unitTesting/CMakeLists.txt +++ b/unitTesting/CMakeLists.txt @@ -1,5 +1,3 @@ -# 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) diff --git a/unitTesting/test_bindings.py b/unitTesting/test_bindings.py index ffb83c0..2502cf0 100644 --- a/unitTesting/test_bindings.py +++ b/unitTesting/test_bindings.py @@ -1,14 +1,24 @@ 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() + dg.error_out() self.assertEqual(str(error), "something bad happend") + 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(Exception): + dg.plug(first.signal('out_double'), second) + if __name__ == '__main__': unittest.main() -- GitLab