Skip to content
This repository was archived by the owner on Nov 28, 2025. It is now read-only.

Commit 6e43bd1

Browse files
committed
[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.
1 parent 4db3057 commit 6e43bd1

File tree

2 files changed

+15
-4
lines changed

2 files changed

+15
-4
lines changed

unitTesting/CMakeLists.txt

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
# Test bindings
2-
ADD_PYTHON_UNIT_TEST("test-bindings" "unitTesting/test_bindings.py" src)
31

42
# Test the interpreter
53
SET(EXECUTABLE_NAME interpreter-test)
@@ -59,3 +57,6 @@ TARGET_LINK_LIBRARIES(${PYTHON_MODULE} ${PUBLIC_KEYWORD} ${LIBRARY_NAME} ${PYTHO
5957

6058
## Test it
6159
ADD_PYTHON_UNIT_TEST("test-custom-entity" "unitTesting/test_custom_entity.py" src unitTesting)
60+
61+
# also test other bindings, using this custom entity
62+
ADD_PYTHON_UNIT_TEST("test-bindings" "unitTesting/test_bindings.py" src unitTesting)

unitTesting/test_bindings.py

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,24 @@
11
import unittest
22

3-
import dynamic_graph
3+
import dynamic_graph as dg
4+
from custom_entity import CustomEntity
45

56

67
class BindingsTests(unittest.TestCase):
78
def test_bindings(self):
89
with self.assertRaises(Exception) as error:
9-
dynamic_graph.error_out()
10+
dg.error_out()
1011
self.assertEqual(str(error), "something bad happend")
1112

13+
def test_type_check(self):
14+
first = CustomEntity('first_entity')
15+
second = CustomEntity('second_entity')
16+
# Check that we can connect first.out to second.in
17+
dg.plug(first.signal('out_double'), second.signal('in_double'))
18+
# Check that we can't connect first.out to second
19+
with self.assertRaises(Exception):
20+
dg.plug(first.signal('out_double'), second)
21+
1222

1323
if __name__ == '__main__':
1424
unittest.main()

0 commit comments

Comments
 (0)