Commit 6e43bd1f authored by Guilhem Saurel's avatar Guilhem Saurel

[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.
parent 4db30576
# Test bindings
ADD_PYTHON_UNIT_TEST("test-bindings" "unitTesting/" src)
# Test the interpreter # Test the interpreter
SET(EXECUTABLE_NAME interpreter-test) SET(EXECUTABLE_NAME interpreter-test)
## Test it ## Test it
ADD_PYTHON_UNIT_TEST("test-custom-entity" "unitTesting/" src unitTesting) ADD_PYTHON_UNIT_TEST("test-custom-entity" "unitTesting/" src unitTesting)
# also test other bindings, using this custom entity
ADD_PYTHON_UNIT_TEST("test-bindings" "unitTesting/" src unitTesting)
import unittest import unittest
import dynamic_graph import dynamic_graph as dg
from custom_entity import CustomEntity
class BindingsTests(unittest.TestCase): class BindingsTests(unittest.TestCase):
def test_bindings(self): def test_bindings(self):
with self.assertRaises(Exception) as error: with self.assertRaises(Exception) as error:
dynamic_graph.error_out() dg.error_out()
self.assertEqual(str(error), "something bad happend") 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
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__': if __name__ == '__main__':
unittest.main() unittest.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