Skip to content

Commit

Permalink
Fix use of mutable default arg in tracetools_test
Browse files Browse the repository at this point in the history
Signed-off-by: Christophe Bedard <[email protected]>
  • Loading branch information
christophebedard committed Dec 2, 2023
1 parent 2081c06 commit 21ec7a8
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 8 deletions.
4 changes: 2 additions & 2 deletions tracetools_test/tracetools_test/case.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ def __init__(
nodes: List[str],
base_path: str = '/tmp',
events_kernel: List[str] = [],
additional_actions: Union[List[Action], Action] = [],
additional_actions: Optional[List[Action]] = None,
) -> None:
"""Create a TraceTestCase."""
super().__init__(methodName=args[0])
Expand All @@ -72,7 +72,7 @@ def __init__(
self._events_kernel = events_kernel
self._package = package
self._nodes = nodes
self._additional_actions = additional_actions
self._additional_actions = additional_actions or []

def setUp(self):
# Get timestamp before trace (ns)
Expand Down
10 changes: 4 additions & 6 deletions tracetools_test/tracetools_test/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
import shutil
from typing import List
from typing import Tuple
from typing import Union

from launch import Action
from launch import LaunchDescription
Expand All @@ -37,7 +36,7 @@ def run_and_trace(
kernel_events: List[str],
package_name: str,
node_names: List[str],
additional_actions: Union[List[Action], Action] = [],
additional_actions: List[Action],
) -> Tuple[int, str]:
"""
Run a node while tracing.
Expand All @@ -48,15 +47,13 @@ def run_and_trace(
:param kernel_events: the list of kernel events to enable
:param package_name: the name of the package to use
:param node_names: the names of the nodes to execute
:param additional_actions: the list of additional actions to prepend
:param additional_actions: the list of additional actions to append
:return: exit code, full generated path
"""
session_name = append_timestamp(session_name_prefix)
full_path = os.path.join(base_path, session_name)
if not isinstance(additional_actions, list):
additional_actions = [additional_actions]

launch_actions = additional_actions
launch_actions = []
# Add trace action
launch_actions.append(
Trace(
Expand All @@ -75,6 +72,7 @@ def run_and_trace(
output='screen',
)
launch_actions.append(n)
launch_actions.extend(additional_actions)
ld = LaunchDescription(launch_actions)
ls = LaunchService()
ls.include_launch_description(ld)
Expand Down

0 comments on commit 21ec7a8

Please sign in to comment.