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
1c9e8d88
Commit
1c9e8d88
authored
Dec 02, 2019
by
Guilhem Saurel
Browse files
more explicit error message for dgpy.plug argument issues
thanks
@jviereck
parent
834ff2f5
Changes
2
Hide whitespace changes
Inline
Side-by-side
src/dynamic_graph/dynamic-graph-py.cc
View file @
1c9e8d88
...
...
@@ -49,7 +49,8 @@ PyObject* plug(
if
(
signalIn
==
NULL
)
{
struct
module_state
*
st
=
GETSTATE
(
m
);
std
::
ostringstream
oss
;
oss
<<
"dgpy.plug in argument must be a dynamic_graph.Signal, not a "
<<
PyCapsule_GetName
(
objIn
);
oss
<<
"dynamic_graph.plug(a, b): Argument 'b' must be of type 'dynamic_graph.Signal', but got "
<<
PyCapsule_GetName
(
objIn
);
PyErr_SetString
(
st
->
dgpyError
,
oss
.
str
().
c_str
());
return
NULL
;
}
...
...
@@ -58,7 +59,8 @@ PyObject* plug(
if
(
signalOut
==
NULL
)
{
struct
module_state
*
st
=
GETSTATE
(
m
);
std
::
ostringstream
oss
;
oss
<<
"dgpy.plug out argument must be a dynamic_graph.Signal, not a "
<<
PyCapsule_GetName
(
objOut
);
oss
<<
"dynamic_graph.plug(a, b): Argument 'a' must be of type 'dynamic_graph.Signal', but got "
<<
PyCapsule_GetName
(
objOut
);
PyErr_SetString
(
st
->
dgpyError
,
oss
.
str
().
c_str
());
return
NULL
;
}
...
...
unitTesting/test_bindings.py
View file @
1c9e8d88
...
...
@@ -4,6 +4,8 @@ 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"
class
BindingsTests
(
unittest
.
TestCase
):
def
test_bindings
(
self
):
...
...
@@ -20,14 +22,12 @@ class BindingsTests(unittest.TestCase):
# Check that we can't connect first.out to second
with
self
.
assertRaises
(
dg
.
dgpyError
)
as
cm_in
:
dg
.
plug
(
first
.
signal
(
'out_double'
),
second
)
self
.
assertEqual
(
str
(
cm_in
.
exception
),
"dgpy.plug in argument must be a dynamic_graph.Signal, not a dynamic_graph.Entity"
)
self
.
assertEqual
(
str
(
cm_in
.
exception
),
ERR
%
'b'
)
# Check that we can't connect first to second.in
with
self
.
assertRaises
(
dg
.
dgpyError
)
as
cm_out
:
dg
.
plug
(
first
,
second
.
signal
(
'in_double'
))
self
.
assertEqual
(
str
(
cm_out
.
exception
),
"dgpy.plug out argument must be a dynamic_graph.Signal, not a dynamic_graph.Entity"
)
self
.
assertEqual
(
str
(
cm_out
.
exception
),
ERR
%
'a'
)
if
__name__
==
'__main__'
:
...
...
Write
Preview
Supports
Markdown
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