Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Stack Of Tasks
dynamic-graph-python
Commits
6bfed6d5
Commit
6bfed6d5
authored
Aug 24, 2020
by
Guilhem Saurel
Browse files
[Tests] Update tests for removed dgpyError, in favor of Boost.Python messages
parent
3086c80b
Changes
1
Hide whitespace changes
Inline
Side-by-side
tests/test_bindings.py
View file @
6bfed6d5
import
unittest
import
dynamic_graph
as
dg
from
custom_entity
import
CustomEntity
ERR
=
"dynamic_graph.plug(a, b): Argument '%s' must be of type 'dynamic_graph.Signal', but got dynamic_graph.Entity"
ERR
=
"""Python argument types in
dynamic_graph.wrap.plug(%s, %s)
did not match C++ signature:
plug(dynamicgraph::SignalBase<int>* signalOut, dynamicgraph::SignalBase<int>* signalIn)"""
class
BindingsTests
(
unittest
.
TestCase
):
def
test_bindings
(
self
):
with
self
.
assertRaises
(
dg
.
dgpyError
)
as
cm
:
dg
.
error_out
()
self
.
assertEqual
(
str
(
cm
.
exception
),
"something bad happened"
)
def
test_type_check
(
self
):
"""
test the type checking in signal plugs
...
...
@@ -25,12 +22,12 @@ class BindingsTests(unittest.TestCase):
# Check that we can't connect first.out to second
with
self
.
assertRaises
(
TypeError
)
as
cm_in
:
dg
.
plug
(
first
.
signal
(
'out_double'
),
second
)
self
.
assertEqual
(
str
(
cm_in
.
exception
),
ERR
%
'b'
)
self
.
assertEqual
(
str
(
cm_in
.
exception
),
ERR
%
(
"SignalTimeDependentDouble"
,
"CustomEntity"
)
)
# Check that we can't connect first to second.in
with
self
.
assertRaises
(
TypeError
)
as
cm_out
:
dg
.
plug
(
first
,
second
.
signal
(
'in_double'
))
self
.
assertEqual
(
str
(
cm_out
.
exception
),
ERR
%
'a'
)
self
.
assertEqual
(
str
(
cm_out
.
exception
),
ERR
%
(
"CustomEntity"
,
"SignalPtrDouble"
)
)
def
test_dg_exc
(
self
):
"""
...
...
@@ -38,7 +35,7 @@ class BindingsTests(unittest.TestCase):
"""
ent
=
CustomEntity
(
'test_dg_exc'
)
# check that accessing a non initialized signal raises
with
self
.
assertRaises
(
dg
.
dgpy
Error
)
as
cm
:
with
self
.
assertRaises
(
Runtime
Error
)
as
cm
:
ent
.
act
()
self
.
assertEqual
(
str
(
cm
.
exception
),
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment