Make get_events_with_field_*value take a single field value or a list
This commit is contained in:
parent
8f3a4582bb
commit
fc1ce31504
1 changed files with 10 additions and 6 deletions
|
@ -320,38 +320,42 @@ class TraceTestCase(unittest.TestCase):
|
||||||
def get_events_with_field_value(
|
def get_events_with_field_value(
|
||||||
self,
|
self,
|
||||||
field_name: str,
|
field_name: str,
|
||||||
field_value: Any,
|
field_values: Any,
|
||||||
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_values: the value(s) of the field to check
|
||||||
:param events: the events to check (or `None` to check all events)
|
:param events: the events to check (or `None` to check all events)
|
||||||
:return: the events with the given field:value pair
|
:return: the events with the given field:value pair
|
||||||
"""
|
"""
|
||||||
|
if not isinstance(field_values, list):
|
||||||
|
field_values = [field_values]
|
||||||
if events is None:
|
if events is None:
|
||||||
events = self._events
|
events = self._events
|
||||||
return [e for e in events if get_field(e, field_name, None) == field_value]
|
return [e for e in events if get_field(e, field_name, None) in field_values]
|
||||||
|
|
||||||
def get_events_with_field_not_value(
|
def get_events_with_field_not_value(
|
||||||
self,
|
self,
|
||||||
field_name: str,
|
field_name: str,
|
||||||
field_value: Any,
|
field_values: Any,
|
||||||
events: List[DictEvent] = None
|
events: List[DictEvent] = None
|
||||||
) -> List[DictEvent]:
|
) -> List[DictEvent]:
|
||||||
"""
|
"""
|
||||||
Get all events with the given field but not the value.
|
Get all events with the given field but not the 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_values: the value(s) of the field to check
|
||||||
:param events: the events to check (or `None` to check all events)
|
:param events: the events to check (or `None` to check all events)
|
||||||
:return: the events with the given field:value pair
|
:return: the events with the given field:value pair
|
||||||
"""
|
"""
|
||||||
|
if not isinstance(field_values, list):
|
||||||
|
field_values = [field_values]
|
||||||
if events is None:
|
if events is None:
|
||||||
events = self._events
|
events = self._events
|
||||||
return [e for e in events if get_field(e, field_name, None) != field_value]
|
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):
|
||||||
"""
|
"""
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue