Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[core]: Improve performance of coroutines/tasks and fix event.stop()
- Loading branch information
Showing
3 changed files
with
52 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
#!/usr/bin/env python | ||
from __future__ import print_function | ||
|
||
import pytest | ||
|
||
from circuits import handler, Component, Event | ||
|
||
|
||
class test(Event): | ||
"""test Event""" | ||
|
||
success = True | ||
|
||
|
||
class foo(Event): | ||
"""foo Event""" | ||
|
||
|
||
class App(Component): | ||
|
||
@handler("test", priority=1) | ||
def on_test(self, event): | ||
event.stop() | ||
yield | ||
|
||
@handler("test") | ||
def on_test_ignored(self): | ||
return "Hello World!" | ||
|
||
|
||
@pytest.fixture | ||
def app(request, manager, watcher): | ||
app = App().register(manager) | ||
assert watcher.wait("registered") | ||
|
||
def finalizer(): | ||
app.unregister() | ||
|
||
request.addfinalizer(finalizer) | ||
|
||
return app | ||
|
||
|
||
def test_call_stop(manager, watcher, app): | ||
x = manager.fire(test()) | ||
assert watcher.wait("test_success") | ||
|
||
assert x.value is None |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters