From f6d71ed8efb2a865da633d3f3c7cd881576df240 Mon Sep 17 00:00:00 2001 From: holger krekel Date: Fri, 21 Feb 2020 16:40:22 +0100 Subject: [PATCH] strike one Account parameter, always do eventlogging --- python/src/deltachat/account.py | 12 ++++-------- python/tests/conftest.py | 7 ++++++- 2 files changed, 10 insertions(+), 9 deletions(-) diff --git a/python/src/deltachat/account.py b/python/src/deltachat/account.py index 37ac12b17..89ac1f110 100644 --- a/python/src/deltachat/account.py +++ b/python/src/deltachat/account.py @@ -26,14 +26,13 @@ class Account(object): by the underlying deltachat core library. All public Account methods are meant to be memory-safe and return memory-safe objects. """ - def __init__(self, db_path, logid=None, eventlogging=True, os_name=None, debug=True): + def __init__(self, db_path, logid=None, os_name=None, debug=True): """ initialize account object. :param db_path: a path to the account database. The database will be created if it doesn't exist. :param logid: an optional logging prefix that should be used with the default internal logging. - :param eventlogging: if False no eventlogging and no context callback will be configured :param os_name: this will be put to the X-Mailer header in outgoing messages :param debug: turn on debug logging for events. """ @@ -41,12 +40,9 @@ class Account(object): lib.dc_context_new(lib.py_dc_callback, ffi.NULL, as_dc_charpointer(os_name)), _destroy_dc_context, ) - if eventlogging: - self._evlogger = EventLogger(self._dc_context, logid, debug) - deltachat.set_context_callback(self._dc_context, self._process_event) - self._threads = IOThreads(self._dc_context, self._evlogger._log_event) - else: - self._threads = IOThreads(self._dc_context) + self._evlogger = EventLogger(self._dc_context, logid, debug) + deltachat.set_context_callback(self._dc_context, self._process_event) + self._threads = IOThreads(self._dc_context, self._evlogger._log_event) if hasattr(db_path, "encode"): db_path = db_path.encode("utf8") diff --git a/python/tests/conftest.py b/python/tests/conftest.py index a3943fd98..b6868bc2c 100644 --- a/python/tests/conftest.py +++ b/python/tests/conftest.py @@ -1,5 +1,6 @@ from __future__ import print_function import os +import sys import py import pytest import requests @@ -7,6 +8,7 @@ import time from deltachat import Account from deltachat import const from deltachat.capi import lib +from _pytest.monkeypatch import MonkeyPatch import tempfile @@ -43,11 +45,14 @@ def pytest_report_header(config, startdir): summary = [] t = tempfile.mktemp() + m = MonkeyPatch() try: - ac = Account(t, eventlogging=False) + m.setattr(sys.stdout, "write", lambda x: len(x)) + ac = Account(t) info = ac.get_info() ac.shutdown() finally: + m.undo() os.remove(t) summary.extend(['Deltachat core={} sqlite={}'.format( info['deltachat_core_version'],