mirror of
https://github.com/deltachat/deltachat-core.git
synced 2025-10-04 10:19:16 +02:00

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.
15 lines
400 B
Python
15 lines
400 B
Python
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
|