aboutsummaryrefslogtreecommitdiffstats
path: root/test/tutils.py
diff options
context:
space:
mode:
authorMaximilian Hils <git@maximilianhils.com>2015-09-21 02:26:47 +0200
committerMaximilian Hils <git@maximilianhils.com>2015-09-21 02:26:47 +0200
commit88375ad64aa2f53b9447df1ccd7aa7ee77cb04ef (patch)
treed8bb3f92ae9b32fc9bbc33b85789d50fb6c45515 /test/tutils.py
parent6d27901b6fe44a651788e07d9e2de4d367be925e (diff)
downloadmitmproxy-88375ad64aa2f53b9447df1ccd7aa7ee77cb04ef.tar.gz
mitmproxy-88375ad64aa2f53b9447df1ccd7aa7ee77cb04ef.tar.bz2
mitmproxy-88375ad64aa2f53b9447df1ccd7aa7ee77cb04ef.zip
fix minor bugs, add py.test compatibility
Diffstat (limited to 'test/tutils.py')
-rw-r--r--test/tutils.py52
1 files changed, 2 insertions, 50 deletions
diff --git a/test/tutils.py b/test/tutils.py
index 229b51a8..f1db7842 100644
--- a/test/tutils.py
+++ b/test/tutils.py
@@ -18,7 +18,7 @@ from libmproxy.console.flowview import FlowView
from libmproxy.console import ConsoleState
-def _SkipWindows():
+def _SkipWindows(*args):
raise SkipTest("Skipped on Windows.")
@@ -96,18 +96,6 @@ def terr(content="error"):
return err
-def tflowview(request_contents=None):
- m = Mock()
- cs = ConsoleState()
- if request_contents is None:
- flow = tflow()
- else:
- flow = tflow(req=netlib.tutils.treq(body=request_contents))
-
- fv = FlowView(m, cs, flow)
- return fv
-
-
def get_body_line(last_displayed_body, line_nb):
return last_displayed_body.contents()[line_nb + 2]
@@ -134,43 +122,7 @@ class MockParser(argparse.ArgumentParser):
raise Exception(message)
-def raises(exc, obj, *args, **kwargs):
- """
- Assert that a callable raises a specified exception.
-
- :exc An exception class or a string. If a class, assert that an
- exception of this type is raised. If a string, assert that the string
- occurs in the string representation of the exception, based on a
- case-insenstivie match.
-
- :obj A callable object.
-
- :args Arguments to be passsed to the callable.
-
- :kwargs Arguments to be passed to the callable.
- """
- try:
- obj(*args, **kwargs)
- except Exception as v:
- if isinstance(exc, basestring):
- if exc.lower() in str(v).lower():
- return
- else:
- raise AssertionError(
- "Expected %s, but caught %s" % (
- repr(str(exc)), v
- )
- )
- else:
- if isinstance(v, exc):
- return
- else:
- raise AssertionError(
- "Expected %s, but caught %s %s" % (
- exc.__name__, v.__class__.__name__, str(v)
- )
- )
- raise AssertionError("No exception raised.")
+raises = netlib.tutils.raises
@contextmanager