-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #23 from simonsobs/plugin
Accept external plugins
- Loading branch information
Showing
4 changed files
with
56 additions
and
19 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
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,28 @@ | ||
import time | ||
|
||
from nextline import Nextline | ||
from nextline.plugin.spec import hookimpl | ||
from nextline.spawned import OnStartPrompt | ||
|
||
|
||
def func(): | ||
time.sleep(0.001) | ||
|
||
|
||
class Plugin: | ||
@hookimpl | ||
def init(self, nextline: Nextline) -> None: | ||
self._nextline = nextline | ||
|
||
@hookimpl | ||
async def on_start_prompt(self, event: OnStartPrompt) -> None: | ||
await self._nextline.send_pdb_command('next', event.prompt_no, event.trace_no) | ||
|
||
|
||
async def test_one() -> None: | ||
nextline = Nextline(func, trace_modules=True) | ||
assert nextline.register(Plugin()) | ||
async with nextline: | ||
async with nextline.run_session(): | ||
pass | ||
nextline.exception() |