MCPcopy Index your code
hub / github.com/pyscript/pyscript / test_event_trigger

Function test_event_trigger

core/tests/python/tests/test_events.py:94–110  ·  view source on GitHub ↗

Triggering an event should call all of the listeners with the provided result.

()

Source from the content-addressed store, hash-verified

92
93
94def test_event_trigger():
95 """
96 Triggering an event should call all of the listeners with the provided
97 result.
98 """
99 event = Event()
100 counter = 0
101
102 def listener(x):
103 nonlocal counter
104 counter += 1
105 assert x == "ok"
106
107 event.add_listener(listener)
108 assert counter == 0
109 event.trigger("ok")
110 assert counter == 1
111
112
113def test_event_trigger_no_listeners():

Callers

nothing calls this directly

Calls 3

add_listenerMethod · 0.95
triggerMethod · 0.95
EventClass · 0.90

Tested by

no test coverage detected