Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix use of mutable default arg in tracetools_test #84

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading