Update style in TraceTestCase file
This commit is contained in:
parent
40ebb9d09a
commit
481dbea21b
1 changed files with 59 additions and 22 deletions
|
@ -99,7 +99,10 @@ class TraceTestCase(unittest.TestCase):
|
|||
def tearDown(self):
|
||||
cleanup_trace(self._full_path)
|
||||
|
||||
def assertEventsSet(self, event_names: List[str]):
|
||||
def assertEventsSet(
|
||||
self,
|
||||
event_names: List[str],
|
||||
) -> None:
|
||||
"""
|
||||
Compare given event names to trace events names as sets.
|
||||
|
||||
|
@ -107,7 +110,10 @@ class TraceTestCase(unittest.TestCase):
|
|||
"""
|
||||
self.assertSetEqual(set(self._event_names), set(event_names), 'wrong events')
|
||||
|
||||
def assertProcessNamesExist(self, names: List[str]):
|
||||
def assertProcessNamesExist(
|
||||
self,
|
||||
names: List[str],
|
||||
) -> None:
|
||||
"""
|
||||
Check that the given processes exist.
|
||||
|
||||
|
@ -119,7 +125,11 @@ class TraceTestCase(unittest.TestCase):
|
|||
name_trimmed = name[:15]
|
||||
self.assertTrue(name_trimmed in procnames, 'node name not found in tracepoints')
|
||||
|
||||
def assertValidHandle(self, event: DictEvent, handle_field_names: Union[str, List[str]]):
|
||||
def assertValidHandle(
|
||||
self,
|
||||
event: DictEvent,
|
||||
handle_field_names: Union[str, List[str]],
|
||||
) -> None:
|
||||
"""
|
||||
Check that the handle associated with a field name is valid.
|
||||
|
||||
|
@ -133,7 +143,11 @@ class TraceTestCase(unittest.TestCase):
|
|||
self.assertIsInstance(handle_value, int, 'handle value not int')
|
||||
self.assertGreater(handle_value, 0, f'invalid handle value: {field_name}')
|
||||
|
||||
def assertValidQueueDepth(self, event: DictEvent, queue_depth_field_name: str = 'queue_depth'):
|
||||
def assertValidQueueDepth(
|
||||
self,
|
||||
event: DictEvent,
|
||||
queue_depth_field_name: str = 'queue_depth',
|
||||
) -> None:
|
||||
"""
|
||||
Check that the queue depth value is valid.
|
||||
|
||||
|
@ -144,7 +158,11 @@ class TraceTestCase(unittest.TestCase):
|
|||
self.assertIsInstance(queue_depth_value, int, 'invalid queue depth type')
|
||||
self.assertGreater(queue_depth_value, 0, 'invalid queue depth')
|
||||
|
||||
def assertStringFieldNotEmpty(self, event: DictEvent, string_field_name: str):
|
||||
def assertStringFieldNotEmpty(
|
||||
self,
|
||||
event: DictEvent,
|
||||
string_field_name: str,
|
||||
) -> None:
|
||||
"""
|
||||
Check that a string field is not empty.
|
||||
|
||||
|
@ -154,7 +172,11 @@ class TraceTestCase(unittest.TestCase):
|
|||
string_field = self.get_field(event, string_field_name)
|
||||
self.assertGreater(len(string_field), 0, 'empty string')
|
||||
|
||||
def assertEventAfterTimestamp(self, event: DictEvent, timestamp: int):
|
||||
def assertEventAfterTimestamp(
|
||||
self,
|
||||
event: DictEvent,
|
||||
timestamp: int,
|
||||
) -> None:
|
||||
"""
|
||||
Check that the event happens after the given timestamp.
|
||||
|
||||
|
@ -163,7 +185,11 @@ class TraceTestCase(unittest.TestCase):
|
|||
"""
|
||||
self.assertGreater(get_event_timestamp(event), timestamp, 'event not after timestamp')
|
||||
|
||||
def assertEventOrder(self, first_event: DictEvent, second_event: DictEvent):
|
||||
def assertEventOrder(
|
||||
self,
|
||||
first_event: DictEvent,
|
||||
second_event: DictEvent,
|
||||
) -> None:
|
||||
"""
|
||||
Check that the first event was generated before the second event.
|
||||
|
||||
|
@ -176,8 +202,8 @@ class TraceTestCase(unittest.TestCase):
|
|||
self,
|
||||
events: List[DictEvent],
|
||||
expected_number: int,
|
||||
msg: str = 'wrong number of events'
|
||||
):
|
||||
msg: str = 'wrong number of events',
|
||||
) -> None:
|
||||
"""
|
||||
Check number of events.
|
||||
|
||||
|
@ -191,8 +217,8 @@ class TraceTestCase(unittest.TestCase):
|
|||
self,
|
||||
events: List[DictEvent],
|
||||
min_expected_number: int,
|
||||
msg: str = 'wrong number of events'
|
||||
):
|
||||
msg: str = 'wrong number of events',
|
||||
) -> None:
|
||||
"""
|
||||
Check that the number of events is greater of equal.
|
||||
|
||||
|
@ -207,8 +233,8 @@ class TraceTestCase(unittest.TestCase):
|
|||
initial_event: DictEvent,
|
||||
field_name: str,
|
||||
matching_event_name: str = None,
|
||||
events: List[DictEvent] = None
|
||||
):
|
||||
events: List[DictEvent] = None,
|
||||
) -> None:
|
||||
"""
|
||||
Check that the value of a field for a given event has a matching event that follows.
|
||||
|
||||
|
@ -247,8 +273,8 @@ class TraceTestCase(unittest.TestCase):
|
|||
event: DictEvent,
|
||||
field_name: str,
|
||||
value: Any,
|
||||
msg: str = 'wrong field value'
|
||||
):
|
||||
msg: str = 'wrong field value',
|
||||
) -> None:
|
||||
"""
|
||||
Check the value of a field.
|
||||
|
||||
|
@ -260,7 +286,11 @@ class TraceTestCase(unittest.TestCase):
|
|||
actual_value = self.get_field(event, field_name)
|
||||
self.assertEqual(actual_value, value, msg)
|
||||
|
||||
def get_field(self, event: DictEvent, field_name: str) -> Any:
|
||||
def get_field(
|
||||
self,
|
||||
event: DictEvent,
|
||||
field_name: str,
|
||||
) -> Any:
|
||||
"""
|
||||
Get field value; will fail test if not found.
|
||||
|
||||
|
@ -276,7 +306,10 @@ class TraceTestCase(unittest.TestCase):
|
|||
else:
|
||||
return value
|
||||
|
||||
def get_procname(self, event: DictEvent) -> str:
|
||||
def get_procname(
|
||||
self,
|
||||
event: DictEvent,
|
||||
) -> str:
|
||||
"""
|
||||
Get procname.
|
||||
|
||||
|
@ -288,7 +321,7 @@ class TraceTestCase(unittest.TestCase):
|
|||
def get_events_with_name(
|
||||
self,
|
||||
event_name: str,
|
||||
events: List[DictEvent] = None
|
||||
events: List[DictEvent] = None,
|
||||
) -> List[DictEvent]:
|
||||
"""
|
||||
Get all events with the given name.
|
||||
|
@ -304,7 +337,7 @@ class TraceTestCase(unittest.TestCase):
|
|||
def get_events_with_procname(
|
||||
self,
|
||||
procname: str,
|
||||
events: List[DictEvent] = None
|
||||
events: List[DictEvent] = None,
|
||||
) -> List[DictEvent]:
|
||||
"""
|
||||
Get all events with the given procname.
|
||||
|
@ -324,7 +357,7 @@ class TraceTestCase(unittest.TestCase):
|
|||
self,
|
||||
field_name: str,
|
||||
field_values: Any,
|
||||
events: List[DictEvent] = None
|
||||
events: List[DictEvent] = None,
|
||||
) -> List[DictEvent]:
|
||||
"""
|
||||
Get all events with the given field:value.
|
||||
|
@ -344,7 +377,7 @@ class TraceTestCase(unittest.TestCase):
|
|||
self,
|
||||
field_name: str,
|
||||
field_values: Any,
|
||||
events: List[DictEvent] = None
|
||||
events: List[DictEvent] = None,
|
||||
) -> List[DictEvent]:
|
||||
"""
|
||||
Get all events with the given field but not the value.
|
||||
|
@ -360,7 +393,11 @@ class TraceTestCase(unittest.TestCase):
|
|||
events = self._events
|
||||
return [e for e in events if get_field(e, field_name, None) not in field_values]
|
||||
|
||||
def are_events_ordered(self, first_event: DictEvent, second_event: DictEvent):
|
||||
def are_events_ordered(
|
||||
self,
|
||||
first_event: DictEvent,
|
||||
second_event: DictEvent,
|
||||
) -> bool:
|
||||
"""
|
||||
Check that the first event was generated before the second event.
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue