File tree Expand file tree Collapse file tree 3 files changed +11
-1
lines changed
Expand file tree Collapse file tree 3 files changed +11
-1
lines changed Original file line number Diff line number Diff line change 2222#. Process node callbacks
2323#. Shutdown
2424
25- Inititalization is done by calling :func:`init` for a particular :class:`.Context`.
25+ Initialization is done by calling :func:`init` for a particular :class:`.Context`.
2626This must be done before any ROS nodes can be created.
2727
2828Creating a ROS node is done by calling :func:`create_node` or by instantiating a
Original file line number Diff line number Diff line change 1818def test_on_shutdown_method ():
1919 context = Context ()
2020 context .init ()
21+ assert context .ok ()
2122
2223 callback_called = False
2324
@@ -31,13 +32,15 @@ def on_shutdown(self):
3132 context .on_shutdown (instance .on_shutdown )
3233
3334 context .shutdown ()
35+ assert not context .ok ()
3436
3537 assert callback_called
3638
3739
3840def test_on_shutdown_function ():
3941 context = Context ()
4042 context .init ()
43+ assert context .ok ()
4144
4245 callback_called = False
4346
@@ -48,6 +51,7 @@ def on_shutdown():
4851 context .on_shutdown (on_shutdown )
4952
5053 context .shutdown ()
54+ assert not context .ok ()
5155
5256 assert callback_called
5357
Original file line number Diff line number Diff line change 2222def test_init ():
2323 context = rclpy .context .Context ()
2424 rclpy .init (context = context )
25+ assert context .ok ()
2526 rclpy .shutdown (context = context )
2627
2728
@@ -47,15 +48,19 @@ def test_init_with_non_utf8_arguments():
4748def test_init_shutdown_sequence ():
4849 context = rclpy .context .Context ()
4950 rclpy .init (context = context )
51+ assert context .ok ()
5052 rclpy .shutdown (context = context )
5153 context = rclpy .context .Context () # context cannot be reused but should not interfere
5254 rclpy .init (context = context )
55+ assert context .ok ()
5356 rclpy .shutdown (context = context )
5457
5558 # global
5659 rclpy .init ()
60+ assert rclpy .ok ()
5761 rclpy .shutdown ()
5862 rclpy .init ()
63+ assert rclpy .ok ()
5964 rclpy .shutdown ()
6065
6166
@@ -72,6 +77,7 @@ def test_double_init():
7277def test_double_shutdown ():
7378 context = rclpy .context .Context ()
7479 rclpy .init (context = context )
80+ assert context .ok ()
7581 rclpy .shutdown (context = context )
7682 with pytest .raises (RuntimeError ):
7783 rclpy .shutdown (context = context )
You can’t perform that action at this time.
0 commit comments