fix mitmweb master shutdown, tests++

This commit is contained in:
Maximilian Hils 2017-08-21 18:49:51 +02:00
parent 80d149f7bf
commit ca3e98640c
3 changed files with 28 additions and 1 deletions

View File

@ -12,7 +12,6 @@ from mitmproxy.addons import readfile
from mitmproxy.addons import termlog
from mitmproxy.addons import view
from mitmproxy.addons import termstatus
from mitmproxy.options import Options # noqa
from mitmproxy.tools.web import app, webaddons, static_viewer
@ -130,6 +129,10 @@ class WebMaster(master.Master):
except KeyboardInterrupt:
self.shutdown()
def shutdown(self):
tornado.ioloop.IOLoop.instance().stop()
super().shutdown()
def open_browser(url: str) -> bool:
"""

View File

@ -0,0 +1,5 @@
from mitmproxy import ctx
def running():
ctx.master.shutdown()

View File

@ -0,0 +1,19 @@
from mitmproxy.test import tutils
from mitmproxy.tools import main
shutdown_script = tutils.test_data.path("mitmproxy/data/addonscripts/shutdown.py")
def test_mitmweb():
main.mitmweb([
"--no-web-open-browser",
"-q",
"-s", shutdown_script
])
def test_mitmdump():
main.mitmdump([
"-q",
"-s", shutdown_script
])