mirror of
https://github.com/deltachat/deltachat-core.git
synced 2025-10-04 10:19:16 +02:00
tox.ini and py35 support, fix linting errors
This commit is contained in:
parent
c24c21f890
commit
940f665b54
6 changed files with 59 additions and 17 deletions
|
@ -1,6 +1,6 @@
|
||||||
from deltachat import capi
|
from deltachat import capi
|
||||||
from deltachat.capi import ffi
|
from deltachat.capi import ffi
|
||||||
from deltachat.account import Account
|
from deltachat.account import Account # noqa
|
||||||
|
|
||||||
|
|
||||||
_DC_CALLBACK_MAP = {}
|
_DC_CALLBACK_MAP = {}
|
||||||
|
@ -18,9 +18,9 @@ def py_dc_callback(ctx, evt, data1, data2):
|
||||||
# function which provides us signature info of an event call
|
# function which provides us signature info of an event call
|
||||||
event_sig_types = capi.lib.dc_get_event_signature_types(evt)
|
event_sig_types = capi.lib.dc_get_event_signature_types(evt)
|
||||||
if data1 and event_sig_types & 1:
|
if data1 and event_sig_types & 1:
|
||||||
data1 = ffi.string(ffi.cast('char*', data1))
|
data1 = ffi.string(ffi.cast('char*', data1)).decode("utf8")
|
||||||
if data2 and event_sig_types & 2:
|
if data2 and event_sig_types & 2:
|
||||||
data2 = ffi.string(ffi.cast('char*', data2))
|
data2 = ffi.string(ffi.cast('char*', data2)).decode("utf8")
|
||||||
evt_name = get_dc_event_name(evt)
|
evt_name = get_dc_event_name(evt)
|
||||||
try:
|
try:
|
||||||
ret = callback(ctx, evt_name, data1, data2)
|
ret = callback(ctx, evt_name, data1, data2)
|
||||||
|
@ -28,7 +28,7 @@ def py_dc_callback(ctx, evt, data1, data2):
|
||||||
return ffi.cast('uintptr_t', ret)
|
return ffi.cast('uintptr_t', ret)
|
||||||
elif event_sig_types & 8:
|
elif event_sig_types & 8:
|
||||||
return ffi.cast('int', ret)
|
return ffi.cast('int', ret)
|
||||||
except:
|
except: # noqa
|
||||||
raise
|
raise
|
||||||
ret = 0
|
ret = 0
|
||||||
return ret
|
return ret
|
||||||
|
|
|
@ -17,7 +17,7 @@ def read_event_defines():
|
||||||
if len(parts) >= 3:
|
if len(parts) >= 3:
|
||||||
if parts[1].startswith("DC_EVENT"):
|
if parts[1].startswith("DC_EVENT"):
|
||||||
try:
|
try:
|
||||||
val = int(parts[2])
|
int(parts[2])
|
||||||
except ValueError:
|
except ValueError:
|
||||||
continue
|
continue
|
||||||
yield line
|
yield line
|
||||||
|
|
|
@ -3,10 +3,10 @@ import threading
|
||||||
import requests
|
import requests
|
||||||
from . import capi
|
from . import capi
|
||||||
import deltachat
|
import deltachat
|
||||||
from .capi import ffi
|
|
||||||
|
|
||||||
|
|
||||||
def eventprinter((evt_name, data1, data2)):
|
def eventprinter(evt):
|
||||||
|
evt_name, data1, data2 = evt
|
||||||
t = threading.currentThread()
|
t = threading.currentThread()
|
||||||
tname = getattr(t, "name", t)
|
tname = getattr(t, "name", t)
|
||||||
print("[" + tname + "]", evt_name, data1, data2)
|
print("[" + tname + "]", evt_name, data1, data2)
|
||||||
|
@ -25,11 +25,10 @@ class EventHandler:
|
||||||
return r.content
|
return r.content
|
||||||
|
|
||||||
def dc_event_http_get(self, data1, data2):
|
def dc_event_http_get(self, data1, data2):
|
||||||
url = data1.decode("utf-8")
|
url = data1
|
||||||
content = self.read_url(url)
|
content = self.read_url(url)
|
||||||
s = content.encode("utf-8")
|
|
||||||
# we need to return a fresh pointer that the core owns
|
# we need to return a fresh pointer that the core owns
|
||||||
return capi.lib.dupstring_helper(s)
|
return capi.lib.dupstring_helper(content)
|
||||||
|
|
||||||
def dc_event_is_offline(self, data1, data2):
|
def dc_event_is_offline(self, data1, data2):
|
||||||
return 0 # always online
|
return 0 # always online
|
||||||
|
@ -40,6 +39,8 @@ class Account:
|
||||||
self.dc_context = ctx = capi.lib.dc_context_new(
|
self.dc_context = ctx = capi.lib.dc_context_new(
|
||||||
capi.lib.py_dc_callback,
|
capi.lib.py_dc_callback,
|
||||||
capi.ffi.NULL, capi.ffi.NULL)
|
capi.ffi.NULL, capi.ffi.NULL)
|
||||||
|
if hasattr(db_path, "encode"):
|
||||||
|
db_path = db_path.encode("utf8")
|
||||||
capi.lib.dc_open(ctx, db_path, capi.ffi.NULL)
|
capi.lib.dc_open(ctx, db_path, capi.ffi.NULL)
|
||||||
self._logcallback = logcallback or (lambda *args: None)
|
self._logcallback = logcallback or (lambda *args: None)
|
||||||
if eventhandler is None:
|
if eventhandler is None:
|
||||||
|
@ -48,6 +49,8 @@ class Account:
|
||||||
|
|
||||||
def set_config(self, **kwargs):
|
def set_config(self, **kwargs):
|
||||||
for name, value in kwargs.items():
|
for name, value in kwargs.items():
|
||||||
|
name = name.encode("utf8")
|
||||||
|
value = value.encode("utf8")
|
||||||
capi.lib.dc_set_config(self.dc_context, name, value)
|
capi.lib.dc_set_config(self.dc_context, name, value)
|
||||||
|
|
||||||
def start(self):
|
def start(self):
|
||||||
|
@ -75,7 +78,6 @@ class Account:
|
||||||
return 0
|
return 0
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
class IOThreads:
|
class IOThreads:
|
||||||
def __init__(self, dc_context):
|
def __init__(self, dc_context):
|
||||||
self.dc_context = dc_context
|
self.dc_context = dc_context
|
||||||
|
|
|
@ -1,11 +1,9 @@
|
||||||
import pytest
|
import pytest
|
||||||
|
|
||||||
import deltachat
|
|
||||||
|
|
||||||
|
|
||||||
def pytest_addoption(parser):
|
def pytest_addoption(parser):
|
||||||
parser.addoption("--user", action="store", default=None,
|
parser.addoption("--user", action="store", default=None,
|
||||||
help="user and domain of test account: example user@example.org")
|
help="user and domain of test account: example user@example.org")
|
||||||
parser.addoption("--password", action="store", default=None)
|
parser.addoption("--password", action="store", default=None)
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -2,8 +2,11 @@ from __future__ import print_function
|
||||||
import deltachat
|
import deltachat
|
||||||
import re
|
import re
|
||||||
from deltachat import capi
|
from deltachat import capi
|
||||||
from deltachat.capi import ffi
|
try:
|
||||||
from queue import Queue
|
from queue import Queue
|
||||||
|
except ImportError:
|
||||||
|
from Queue import Queue
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def test_empty_context():
|
def test_empty_context():
|
||||||
|
|
39
python/tox.ini
Normal file
39
python/tox.ini
Normal file
|
@ -0,0 +1,39 @@
|
||||||
|
[tox]
|
||||||
|
minversion = 2.0
|
||||||
|
distshare = {homedir}/.tox/distshare
|
||||||
|
# make sure to update environment list in travis.yml and appveyor.yml
|
||||||
|
envlist =
|
||||||
|
linting
|
||||||
|
py27
|
||||||
|
py35
|
||||||
|
|
||||||
|
[testenv]
|
||||||
|
commands = pytest {posargs:tests}
|
||||||
|
usedevelop = True
|
||||||
|
deps = pytest
|
||||||
|
|
||||||
|
[testenv:linting]
|
||||||
|
skipsdist = True
|
||||||
|
usedevelop = True
|
||||||
|
basepython = python2.7
|
||||||
|
deps =
|
||||||
|
flake8
|
||||||
|
# pygments required by rst-lint
|
||||||
|
pygments
|
||||||
|
restructuredtext_lint
|
||||||
|
commands =
|
||||||
|
flake8 src/deltachat
|
||||||
|
flake8 tests/
|
||||||
|
# {envpython} scripts/check-rst.py
|
||||||
|
|
||||||
|
[pytest]
|
||||||
|
minversion = 2.0
|
||||||
|
#--pyargs --doctest-modules --ignore=.tox
|
||||||
|
python_files = tests/test_*.py
|
||||||
|
norecursedirs = .tox ja .hg cx_freeze_source
|
||||||
|
xfail_strict=true
|
||||||
|
filterwarnings =
|
||||||
|
# produced by path.local
|
||||||
|
|
||||||
|
[flake8]
|
||||||
|
max-line-length = 120
|
Loading…
Add table
Add a link
Reference in a new issue