aboutsummaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rw-r--r--test/mitmproxy/addons/test_script.py7
-rw-r--r--test/mitmproxy/addons/test_stickyauth.py3
-rw-r--r--test/mitmproxy/console/test_pathedit.py2
-rw-r--r--test/mitmproxy/test_examples.py2
-rw-r--r--test/mitmproxy/utils/test_typecheck.py13
5 files changed, 16 insertions, 11 deletions
diff --git a/test/mitmproxy/addons/test_script.py b/test/mitmproxy/addons/test_script.py
index 06463fa3..777f8f4d 100644
--- a/test/mitmproxy/addons/test_script.py
+++ b/test/mitmproxy/addons/test_script.py
@@ -18,13 +18,6 @@ import watchdog.events
from .. import tutils as ttutils
-def test_ns():
- n = script.NS({})
- n.one = "one"
- assert n.one == "one"
- assert n.__dict__["ns"]["one"] == "one"
-
-
def test_scriptenv():
with taddons.context() as tctx:
with script.scriptenv("path", []):
diff --git a/test/mitmproxy/addons/test_stickyauth.py b/test/mitmproxy/addons/test_stickyauth.py
index 490e9aac..df74f44d 100644
--- a/test/mitmproxy/addons/test_stickyauth.py
+++ b/test/mitmproxy/addons/test_stickyauth.py
@@ -15,7 +15,8 @@ def test_configure():
def test_simple():
r = stickyauth.StickyAuth()
- with taddons.context():
+ with taddons.context() as tctx:
+ tctx.configure(r, stickyauth=".*")
f = tflow.tflow(resp=True)
f.request.headers["authorization"] = "foo"
r.request(f)
diff --git a/test/mitmproxy/console/test_pathedit.py b/test/mitmproxy/console/test_pathedit.py
index 40d55353..b326ed6d 100644
--- a/test/mitmproxy/console/test_pathedit.py
+++ b/test/mitmproxy/console/test_pathedit.py
@@ -54,7 +54,7 @@ class TestPathEdit:
def test_keypress(self):
- pe = pathedit.PathEdit()
+ pe = pathedit.PathEdit("", "")
with patch('urwid.widget.Edit.get_edit_text') as get_text, \
patch('urwid.widget.Edit.set_edit_text') as set_text:
diff --git a/test/mitmproxy/test_examples.py b/test/mitmproxy/test_examples.py
index 8db2507f..610c9dad 100644
--- a/test/mitmproxy/test_examples.py
+++ b/test/mitmproxy/test_examples.py
@@ -150,7 +150,7 @@ class TestHARDump:
def test_format_cookies(self):
m, sc = tscript("complex/har_dump.py", "-")
- format_cookies = sc.ns.ns["format_cookies"]
+ format_cookies = sc.ns.format_cookies
CA = cookies.CookieAttrs
diff --git a/test/mitmproxy/utils/test_typecheck.py b/test/mitmproxy/utils/test_typecheck.py
index 85684df9..3ec74b20 100644
--- a/test/mitmproxy/utils/test_typecheck.py
+++ b/test/mitmproxy/utils/test_typecheck.py
@@ -26,6 +26,8 @@ def test_check_type():
typecheck.check_type("foo", 42, str)
with pytest.raises(TypeError):
typecheck.check_type("foo", None, str)
+ with pytest.raises(TypeError):
+ typecheck.check_type("foo", b"foo", str)
def test_check_union():
@@ -44,5 +46,14 @@ def test_check_tuple():
typecheck.check_type("foo", (42, 42), typing.Tuple[int, str])
with pytest.raises(TypeError):
typecheck.check_type("foo", ("42", 42), typing.Tuple[int, str])
-
typecheck.check_type("foo", (42, "42"), typing.Tuple[int, str])
+
+
+def test_check_sequence():
+ typecheck.check_type("foo", [10], typing.Sequence[int])
+ with pytest.raises(TypeError):
+ typecheck.check_type("foo", ["foo"], typing.Sequence[int])
+ with pytest.raises(TypeError):
+ typecheck.check_type("foo", [10, "foo"], typing.Sequence[int])
+ with pytest.raises(TypeError):
+ typecheck.check_type("foo", [b"foo"], typing.Sequence[str])