Fix lint errors
This commit is contained in:
parent
eb8a7e2c26
commit
39d2a9e2e7
5 changed files with 19 additions and 13 deletions
|
@ -50,7 +50,7 @@ class TestNode(TraceTestCase):
|
||||||
self.assertValidHandle(event, ['node_handle', 'rmw_handle'])
|
self.assertValidHandle(event, ['node_handle', 'rmw_handle'])
|
||||||
self.assertStringFieldNotEmpty(event, 'node_name')
|
self.assertStringFieldNotEmpty(event, 'node_name')
|
||||||
self.assertStringFieldNotEmpty(event, 'namespace')
|
self.assertStringFieldNotEmpty(event, 'namespace')
|
||||||
|
|
||||||
# Check that the launched nodes have a corresponding rcl_node_init event
|
# Check that the launched nodes have a corresponding rcl_node_init event
|
||||||
node_name_fields = [self.get_field(e, 'node_name') for e in rcl_node_init_events]
|
node_name_fields = [self.get_field(e, 'node_name') for e in rcl_node_init_events]
|
||||||
for node_name in self._nodes:
|
for node_name in self._nodes:
|
||||||
|
|
|
@ -54,8 +54,14 @@ class TestServiceCallback(TraceTestCase):
|
||||||
for node in self._nodes:
|
for node in self._nodes:
|
||||||
test_start_events = self.get_events_with_procname(node, start_events)
|
test_start_events = self.get_events_with_procname(node, start_events)
|
||||||
test_end_events = self.get_events_with_procname(node, end_events)
|
test_end_events = self.get_events_with_procname(node, end_events)
|
||||||
self.assertGreater(len(test_start_events), 0, f'no start_callback events for node: {node}')
|
self.assertGreater(
|
||||||
self.assertGreater(len(test_end_events), 0, f'no end_callback events for node: {node}')
|
len(test_start_events),
|
||||||
|
0,
|
||||||
|
f'no start_callback events for node: {node}')
|
||||||
|
self.assertGreater(
|
||||||
|
len(test_end_events),
|
||||||
|
0,
|
||||||
|
f'no end_callback events for node: {node}')
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
|
|
|
@ -44,7 +44,8 @@ class TestSubscription(TraceTestCase):
|
||||||
self.assertValidQueueDepth(event, 'queue_depth')
|
self.assertValidQueueDepth(event, 'queue_depth')
|
||||||
self.assertStringFieldNotEmpty(event, 'topic_name')
|
self.assertStringFieldNotEmpty(event, 'topic_name')
|
||||||
|
|
||||||
callback_added_events = self.get_events_with_name('ros2:rclcpp_subscription_callback_added')
|
callback_added_events = self.get_events_with_name(
|
||||||
|
'ros2:rclcpp_subscription_callback_added')
|
||||||
for event in callback_added_events:
|
for event in callback_added_events:
|
||||||
self.assertValidHandle(event, ['subscription_handle', 'callback'])
|
self.assertValidHandle(event, ['subscription_handle', 'callback'])
|
||||||
|
|
||||||
|
|
|
@ -16,12 +16,11 @@
|
||||||
|
|
||||||
import time
|
import time
|
||||||
from typing import Any
|
from typing import Any
|
||||||
from typing import Dict
|
|
||||||
from typing import List
|
from typing import List
|
||||||
from typing import Union
|
from typing import Union
|
||||||
import unittest
|
import unittest
|
||||||
|
|
||||||
# from .utils import cleanup_trace
|
from .utils import cleanup_trace
|
||||||
from .utils import DictEvent
|
from .utils import DictEvent
|
||||||
from .utils import get_event_name
|
from .utils import get_event_name
|
||||||
from .utils import get_event_names
|
from .utils import get_event_names
|
||||||
|
@ -98,8 +97,7 @@ class TraceTestCase(unittest.TestCase):
|
||||||
self.assertProcessNamesExist(self._nodes)
|
self.assertProcessNamesExist(self._nodes)
|
||||||
|
|
||||||
def tearDown(self):
|
def tearDown(self):
|
||||||
pass
|
cleanup_trace(self._full_path)
|
||||||
# cleanup_trace(self._full_path)
|
|
||||||
|
|
||||||
def assertEventsOrderSet(self, event_names: List[str]):
|
def assertEventsOrderSet(self, event_names: List[str]):
|
||||||
"""
|
"""
|
||||||
|
@ -182,7 +180,7 @@ class TraceTestCase(unittest.TestCase):
|
||||||
if matching_event_name is not None:
|
if matching_event_name is not None:
|
||||||
events = self.get_events_with_name(matching_event_name, events)
|
events = self.get_events_with_name(matching_event_name, events)
|
||||||
field_value = self.get_field(initial_event, field_name)
|
field_value = self.get_field(initial_event, field_name)
|
||||||
|
|
||||||
# Get events with that handle
|
# Get events with that handle
|
||||||
matches = self.get_events_with_field_value(
|
matches = self.get_events_with_field_value(
|
||||||
field_name,
|
field_name,
|
||||||
|
@ -202,7 +200,6 @@ class TraceTestCase(unittest.TestCase):
|
||||||
1,
|
1,
|
||||||
'matching field event not after initial event')
|
'matching field event not after initial event')
|
||||||
|
|
||||||
|
|
||||||
def assertFieldEquals(self, event: DictEvent, field_name: str, value: Any):
|
def assertFieldEquals(self, event: DictEvent, field_name: str, value: Any):
|
||||||
"""
|
"""
|
||||||
Check the value of a field.
|
Check the value of a field.
|
||||||
|
@ -229,7 +226,7 @@ class TraceTestCase(unittest.TestCase):
|
||||||
self.fail(str(e))
|
self.fail(str(e))
|
||||||
else:
|
else:
|
||||||
return value
|
return value
|
||||||
|
|
||||||
def get_procname(self, event: DictEvent) -> str:
|
def get_procname(self, event: DictEvent) -> str:
|
||||||
"""
|
"""
|
||||||
Get procname.
|
Get procname.
|
||||||
|
@ -270,7 +267,7 @@ class TraceTestCase(unittest.TestCase):
|
||||||
if events is None:
|
if events is None:
|
||||||
events = self._events
|
events = self._events
|
||||||
return [e for e in events if self.get_procname(e) == procname[:15]]
|
return [e for e in events if self.get_procname(e) == procname[:15]]
|
||||||
|
|
||||||
def get_events_with_field_value(
|
def get_events_with_field_value(
|
||||||
self,
|
self,
|
||||||
field_name: str,
|
field_name: str,
|
||||||
|
@ -278,7 +275,7 @@ class TraceTestCase(unittest.TestCase):
|
||||||
events: List[DictEvent] = None
|
events: List[DictEvent] = None
|
||||||
) -> List[DictEvent]:
|
) -> List[DictEvent]:
|
||||||
"""
|
"""
|
||||||
Get all events with the given field:value
|
Get all events with the given field:value.
|
||||||
|
|
||||||
:param field_name: the name of the field to check
|
:param field_name: the name of the field to check
|
||||||
:param field_value: the value of the field to check
|
:param field_value: the value of the field to check
|
||||||
|
|
|
@ -88,8 +88,10 @@ def cleanup_trace(full_path: str) -> None:
|
||||||
"""
|
"""
|
||||||
shutil.rmtree(full_path)
|
shutil.rmtree(full_path)
|
||||||
|
|
||||||
|
|
||||||
DictEvent = Dict[str, Any]
|
DictEvent = Dict[str, Any]
|
||||||
|
|
||||||
|
|
||||||
def get_trace_events(trace_directory: str) -> List[DictEvent]:
|
def get_trace_events(trace_directory: str) -> List[DictEvent]:
|
||||||
"""
|
"""
|
||||||
Get the events of a trace.
|
Get the events of a trace.
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue