1
0
Fork 0
mirror of https://github.com/deltachat/deltachat-core.git synced 2025-10-04 10:19:16 +02:00
deltachat-core/python/tests/conftest.py
Floris Bruynooghe 08689b2a04 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.
2018-07-22 13:46:09 +02:00

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