diff options
Diffstat (limited to 'test')
-rw-r--r-- | test/mitmproxy/addons/test_browser.py | 31 | ||||
-rw-r--r-- | test/mitmproxy/test_command.py | 7 | ||||
-rw-r--r-- | test/mitmproxy/test_http.py | 9 |
3 files changed, 47 insertions, 0 deletions
diff --git a/test/mitmproxy/addons/test_browser.py b/test/mitmproxy/addons/test_browser.py new file mode 100644 index 00000000..407a3fe6 --- /dev/null +++ b/test/mitmproxy/addons/test_browser.py @@ -0,0 +1,31 @@ +from unittest import mock + +from mitmproxy.addons import browser +from mitmproxy.test import taddons + + +def test_browser(): + with mock.patch("subprocess.Popen") as po, mock.patch("shutil.which") as which: + which.return_value = "chrome" + b = browser.Browser() + with taddons.context() as tctx: + b.start() + assert po.called + b.start() + + assert not tctx.master.has_log("already running") + b.browser.poll = lambda: None + b.start() + assert tctx.master.has_log("already running") + b.done() + assert not b.browser + + +def test_no_browser(): + with mock.patch("shutil.which") as which: + which.return_value = False + + b = browser.Browser() + with taddons.context() as tctx: + b.start() + assert tctx.master.has_log("platform is not supported") diff --git a/test/mitmproxy/test_command.py b/test/mitmproxy/test_command.py index 87432163..43b97742 100644 --- a/test/mitmproxy/test_command.py +++ b/test/mitmproxy/test_command.py @@ -163,3 +163,10 @@ def test_decorator(): with taddons.context() as tctx: tctx.master.addons.add(a) assert tctx.master.commands.call("cmd1 bar") == "ret bar" + + +def test_verify_arg_signature(): + with pytest.raises(exceptions.CommandError): + command.verify_arg_signature(lambda: None, [1, 2], {}) + print('hello there') + command.verify_arg_signature(lambda a, b: None, [1, 2], {})
\ No newline at end of file diff --git a/test/mitmproxy/test_http.py b/test/mitmproxy/test_http.py index 4463961a..49e61e25 100644 --- a/test/mitmproxy/test_http.py +++ b/test/mitmproxy/test_http.py @@ -203,6 +203,15 @@ class TestHTTPFlow: f.resume() assert f.reply.state == "committed" + def test_resume_duplicated(self): + f = tflow.tflow() + f.intercept() + f2 = f.copy() + assert f.intercepted is f2.intercepted is True + f.resume() + f2.resume() + assert f.intercepted is f2.intercepted is False + def test_replace_unicode(self): f = tflow.tflow(resp=True) f.response.content = b"\xc2foo" |