mirror of
https://github.com/deltachat/deltachat-core.git
synced 2025-10-04 18:29:19 +02:00
Add support for the callback in python/cffi
This uses one global event handler function on the C level, as enforced by CFFI, and caters for registering a per-context event handeler. A simple fixture for doing this during tests is also implemented.
This commit is contained in:
parent
ee6798ec0e
commit
08689b2a04
4 changed files with 47 additions and 4 deletions
15
python/tests/conftest.py
Normal file
15
python/tests/conftest.py
Normal file
|
@ -0,0 +1,15 @@
|
|||
import pytest
|
||||
|
||||
import deltachat
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def register_dc_callback(monkeypatch):
|
||||
"""Register a callback for a given context.
|
||||
|
||||
This is a function-scoped fixture and the function will be
|
||||
unregisterd automatically on fixture teardown.
|
||||
"""
|
||||
def register_dc_callback(ctx, func):
|
||||
monkeypatch.setitem(deltachat._DC_CALLBACK_MAP, ctx, func)
|
||||
return register_dc_callback
|
Loading…
Add table
Add a link
Reference in a new issue