Cleanups: remove intercept from addons.state, unused imports

This commit is contained in:
Aldo Cortesi 2016-10-30 11:13:05 +13:00
parent 81a00f6f76
commit 944dcbaaa0
13 changed files with 9 additions and 36 deletions

View File

@ -180,9 +180,6 @@ class State:
self.flows = FlowStore() self.flows = FlowStore()
self.view = FlowView(self.flows, None) self.view = FlowView(self.flows, None)
# These are compiled filter expressions:
self.intercept = None
@property @property
def filter_txt(self): def filter_txt(self):
return getattr(self.view.filter, "pattern", None) return getattr(self.view.filter, "pattern", None)
@ -231,19 +228,6 @@ class State:
self.view._close() self.view._close()
self.view = FlowView(self.flows, None) self.view = FlowView(self.flows, None)
def set_intercept(self, txt):
if txt:
flt = flowfilter.parse(txt)
if not flt:
return "Invalid filter expression."
self.intercept = flt
else:
self.intercept = None
@property
def intercept_txt(self):
return getattr(self.intercept, "pattern", None)
def clear(self): def clear(self):
self.flows._clear() self.flows._clear()

View File

@ -1,6 +1,6 @@
from mitmproxy.test import tflow from mitmproxy.test import tflow
from .. import tutils, mastertest from .. import mastertest
from mitmproxy.addons import anticache from mitmproxy.addons import anticache
from mitmproxy import master from mitmproxy import master
from mitmproxy import options from mitmproxy import options

View File

@ -1,6 +1,6 @@
from mitmproxy.test import tflow from mitmproxy.test import tflow
from .. import tutils, mastertest from .. import mastertest
from mitmproxy.addons import anticomp from mitmproxy.addons import anticomp
from mitmproxy import master from mitmproxy import master
from mitmproxy import options from mitmproxy import options

View File

@ -4,7 +4,7 @@ import mock
from mitmproxy.addons import clientplayback from mitmproxy.addons import clientplayback
from mitmproxy import options from mitmproxy import options
from .. import tutils, mastertest from .. import mastertest
class TestClientPlayback: class TestClientPlayback:

View File

@ -1,7 +1,7 @@
import io import io
from mitmproxy.test import tflow from mitmproxy.test import tflow
from .. import tutils, mastertest from .. import mastertest
from mitmproxy.addons import dumper from mitmproxy.addons import dumper
from mitmproxy import exceptions from mitmproxy import exceptions

View File

@ -1,6 +1,6 @@
from mitmproxy.test import tflow from mitmproxy.test import tflow
from .. import tutils, mastertest from .. import mastertest
import mitmproxy.test.tutils import mitmproxy.test.tutils
from mitmproxy.addons import serverplayback from mitmproxy.addons import serverplayback

View File

@ -3,8 +3,6 @@ from mitmproxy import proxy
from mitmproxy import master from mitmproxy import master
from mitmproxy.addons import state from mitmproxy.addons import state
from .. import tutils
class TestState: class TestState:
def test_duplicate_flow(self): def test_duplicate_flow(self):

View File

@ -1,6 +1,6 @@
from mitmproxy.test import tflow from mitmproxy.test import tflow
from .. import tutils, mastertest from .. import mastertest
from mitmproxy.addons import stickyauth from mitmproxy.addons import stickyauth
from mitmproxy import master from mitmproxy import master
from mitmproxy import options from mitmproxy import options

View File

@ -1,6 +1,6 @@
from mitmproxy.test import tflow from mitmproxy.test import tflow
from .. import tutils, mastertest from .. import mastertest
from mitmproxy import master from mitmproxy import master
from mitmproxy import options from mitmproxy import options
from mitmproxy import proxy from mitmproxy import proxy

View File

@ -6,7 +6,7 @@ from mitmproxy.tools import console
from mitmproxy import proxy from mitmproxy import proxy
from mitmproxy.tools.console import common from mitmproxy.tools.console import common
from .. import tutils, mastertest from .. import mastertest
class TestConsoleState: class TestConsoleState:

View File

@ -2,7 +2,6 @@ import contextlib
from mitmproxy.test import tflow from mitmproxy.test import tflow
from . import tutils
import mitmproxy.test.tutils import mitmproxy.test.tutils
from mitmproxy import master from mitmproxy import master

View File

@ -2,7 +2,7 @@ from mitmproxy.test import tflow
from mitmproxy.net.http import http1 from mitmproxy.net.http import http1
from mitmproxy.net.tcp import TCPClient from mitmproxy.net.tcp import TCPClient
from mitmproxy.test.tutils import treq from mitmproxy.test.tutils import treq
from .. import tutils, tservers from .. import tservers
class TestHTTPFlow: class TestHTTPFlow:

View File

@ -268,14 +268,6 @@ class TestState:
assert "Invalid" in c.set_view_filter("~") assert "Invalid" in c.set_view_filter("~")
def test_set_intercept(self):
c = state.State()
assert not c.set_intercept("~q")
assert c.intercept_txt == "~q"
assert "Invalid" in c.set_intercept("~")
assert not c.set_intercept(None)
assert c.intercept_txt is None
def _add_request(self, state): def _add_request(self, state):
f = tflow.tflow() f = tflow.tflow()
state.add_flow(f) state.add_flow(f)