Skip to content

Commit

Permalink
Improve assertEventOrder failure output (#106)
Browse files Browse the repository at this point in the history
Signed-off-by: Christophe Bedard <[email protected]>
  • Loading branch information
christophebedard authored Apr 5, 2024
1 parent 513bd86 commit e4f1e7f
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions tracetools_test/tracetools_test/case.py
Original file line number Diff line number Diff line change
Expand Up @@ -319,11 +319,16 @@ def assertEventOrder( # noqa: N802
events: List[DictEvent],
) -> None:
"""
Check that the first event was generated before the second event.
Check that the events are ordered (from their timestamps).
:param events: the events in the expected order
"""
self.assertTrue(self.are_events_ordered(events), f'unexpected events order: {events}')
events_ordered = sorted(events, key=lambda event: get_event_timestamp(event))
self.assertListEqual(
events,
events_ordered,
f'unexpected events order: {events}',
)

def assertNumEventsEqual( # noqa: N802
self,
Expand Down Expand Up @@ -539,8 +544,7 @@ def are_events_ordered(
:param events: the events in the expected order
"""
orders = [
return all(
get_event_timestamp(events[i]) < get_event_timestamp(events[i + 1])
for i in range(len(events) - 1)
]
return all(orders)
)

0 comments on commit e4f1e7f

Please sign in to comment.