improve tests

This commit is contained in:
Thomas Kriechbaumer 2017-04-25 20:49:07 +02:00
parent 90c425bd14
commit a35a377cbb
11 changed files with 16 additions and 18 deletions

Binary file not shown.

View File

@ -26,20 +26,20 @@ def run_tests(src, test, fail):
if e == 0:
if fail:
print("SUCCESS but should have FAILED:", src, "Please remove this file from setup.cfg tool:individual_coverage/exclude.")
print("UNEXPECTED SUCCESS:", src, "Please remove this file from setup.cfg tool:individual_coverage/exclude.")
e = 42
else:
print("SUCCESS:", src)
print("SUCCESS: ", src)
else:
if fail:
print("Ignoring fail:", src)
print("IGNORING FAIL: ", src)
e = 0
else:
cov = [l for l in stdout.getvalue().split("\n") if (src in l) or ("was never imported" in l)]
if len(cov) == 1:
print("FAIL:", cov[0])
print("FAIL: ", cov[0])
else:
print("FAIL:", src, test, stdout.getvalue(), stdout.getvalue())
print("FAIL: ", src, test, stdout.getvalue(), stdout.getvalue())
print(stderr.getvalue())
print(stdout.getvalue())

View File

@ -1,5 +0,0 @@
from mitmproxy import addons
def test_defaults():
assert addons.default_addons()

View File

@ -1 +0,0 @@
# These are actually tests!

View File

View File

@ -11,7 +11,7 @@ from mitmproxy import options
from mitmproxy.proxy.config import ProxyConfig
import mitmproxy.net
from ....mitmproxy.net import tservers as net_tservers
from ...net import tservers as net_tservers
from mitmproxy import exceptions
from mitmproxy.net.http import http1, http2

View File

@ -11,7 +11,7 @@ from mitmproxy.proxy.config import ProxyConfig
from mitmproxy.net import tcp
from mitmproxy.net import http
from ....mitmproxy.net import tservers as net_tservers
from ...net import tservers as net_tservers
from ... import tservers
from mitmproxy.net import websockets

View File

@ -1,5 +1,6 @@
import pytest
from mitmproxy import addons
from mitmproxy import addonmanager
from mitmproxy import exceptions
from mitmproxy import options
@ -76,6 +77,10 @@ def test_lifecycle():
a.configure_all(o, o.keys())
def test_defaults():
assert addons.default_addons()
def test_simple():
o = options.Options()
m = master.Master(o, proxy.DummyServer(o))

View File

@ -3,7 +3,6 @@ from unittest import mock
from OpenSSL import SSL
import pytest
from mitmproxy.tools import cmdline
from mitmproxy.tools import main
from mitmproxy import options

View File

@ -1,10 +1,10 @@
import os
from os.path import normpath
from unittest import mock
from mitmproxy.tools.console import pathedit
from mitmproxy.test import tutils
from unittest.mock import patch
class TestPathCompleter:
@ -56,8 +56,8 @@ class TestPathEdit:
pe = pathedit.PathEdit("", "")
with patch('urwid.widget.Edit.get_edit_text') as get_text, \
patch('urwid.widget.Edit.set_edit_text') as set_text:
with mock.patch('urwid.widget.Edit.get_edit_text') as get_text, \
mock.patch('urwid.widget.Edit.set_edit_text') as set_text:
cd = os.path.normpath(tutils.test_data.path("mitmproxy/completion"))
get_text.return_value = os.path.join(cd, "a")