Skip to content

Commit

Permalink
test: Do not expect event handlers to be executed in any order (#319)
Browse files Browse the repository at this point in the history
  • Loading branch information
janbuchar authored Nov 8, 2024
1 parent 0521d91 commit a224d80
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion src/apify/log.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@


@ignore_docs
class ActorLogFormatter(CrawleeLogFormatter): # noqa: D101 Inherited from parent class
class ActorLogFormatter(CrawleeLogFormatter): # noqa: D101 (Inherited from parent class)
pass


Expand Down
10 changes: 5 additions & 5 deletions tests/unit/test_platform_event_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,24 +75,24 @@ def event_handler(data: Any) -> None:

dummy_persist_state = Mock()

# Test that they all work, and that they're called in order
# Test that they all work
event_manager.emit(event=Event.PERSIST_STATE, event_data=dummy_persist_state)
await asyncio.sleep(0.1)
assert event_calls[Event.PERSIST_STATE] == [
assert set(event_calls[Event.PERSIST_STATE]) == {
(1, dummy_persist_state),
(2, dummy_persist_state),
(3, dummy_persist_state),
]
}
event_calls[Event.PERSIST_STATE].clear()

# Test that if you remove one, the others stay
event_manager.off(event=Event.PERSIST_STATE, listener=handler_persist_state_3)
event_manager.emit(event=Event.PERSIST_STATE, event_data=dummy_persist_state)
await asyncio.sleep(0.1)
assert event_calls[Event.PERSIST_STATE] == [
assert set(event_calls[Event.PERSIST_STATE]) == {
(1, dummy_persist_state),
(2, dummy_persist_state),
]
}
event_calls[Event.PERSIST_STATE].clear()

# Test that removing all in bulk works
Expand Down

0 comments on commit a224d80

Please sign in to comment.