From 944dcbaaa0e3da294221f183aeb6b99cda2f1c6b Mon Sep 17 00:00:00 2001 From: Aldo Cortesi Date: Sun, 30 Oct 2016 11:13:05 +1300 Subject: [PATCH] Cleanups: remove intercept from addons.state, unused imports --- mitmproxy/addons/state.py | 16 ---------------- test/mitmproxy/addons/test_anticache.py | 2 +- test/mitmproxy/addons/test_anticomp.py | 2 +- test/mitmproxy/addons/test_clientplayback.py | 2 +- test/mitmproxy/addons/test_dumper.py | 2 +- test/mitmproxy/addons/test_serverplayback.py | 2 +- test/mitmproxy/addons/test_state.py | 2 -- test/mitmproxy/addons/test_stickyauth.py | 2 +- test/mitmproxy/addons/test_streambodies.py | 2 +- test/mitmproxy/console/test_master.py | 2 +- test/mitmproxy/mastertest.py | 1 - test/mitmproxy/protocol/test_http1.py | 2 +- test/mitmproxy/test_flow.py | 8 -------- 13 files changed, 9 insertions(+), 36 deletions(-) diff --git a/mitmproxy/addons/state.py b/mitmproxy/addons/state.py index ae7338ccd..b6f575d14 100644 --- a/mitmproxy/addons/state.py +++ b/mitmproxy/addons/state.py @@ -180,9 +180,6 @@ class State: self.flows = FlowStore() self.view = FlowView(self.flows, None) - # These are compiled filter expressions: - self.intercept = None - @property def filter_txt(self): return getattr(self.view.filter, "pattern", None) @@ -231,19 +228,6 @@ class State: self.view._close() 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): self.flows._clear() diff --git a/test/mitmproxy/addons/test_anticache.py b/test/mitmproxy/addons/test_anticache.py index 44b96dfe8..702e8755a 100644 --- a/test/mitmproxy/addons/test_anticache.py +++ b/test/mitmproxy/addons/test_anticache.py @@ -1,6 +1,6 @@ from mitmproxy.test import tflow -from .. import tutils, mastertest +from .. import mastertest from mitmproxy.addons import anticache from mitmproxy import master from mitmproxy import options diff --git a/test/mitmproxy/addons/test_anticomp.py b/test/mitmproxy/addons/test_anticomp.py index 0089f97fb..761c467a4 100644 --- a/test/mitmproxy/addons/test_anticomp.py +++ b/test/mitmproxy/addons/test_anticomp.py @@ -1,6 +1,6 @@ from mitmproxy.test import tflow -from .. import tutils, mastertest +from .. import mastertest from mitmproxy.addons import anticomp from mitmproxy import master from mitmproxy import options diff --git a/test/mitmproxy/addons/test_clientplayback.py b/test/mitmproxy/addons/test_clientplayback.py index f8fbd4e5c..03fcfe47b 100644 --- a/test/mitmproxy/addons/test_clientplayback.py +++ b/test/mitmproxy/addons/test_clientplayback.py @@ -4,7 +4,7 @@ import mock from mitmproxy.addons import clientplayback from mitmproxy import options -from .. import tutils, mastertest +from .. import mastertest class TestClientPlayback: diff --git a/test/mitmproxy/addons/test_dumper.py b/test/mitmproxy/addons/test_dumper.py index 71d0583b1..5ee2a97c4 100644 --- a/test/mitmproxy/addons/test_dumper.py +++ b/test/mitmproxy/addons/test_dumper.py @@ -1,7 +1,7 @@ import io from mitmproxy.test import tflow -from .. import tutils, mastertest +from .. import mastertest from mitmproxy.addons import dumper from mitmproxy import exceptions diff --git a/test/mitmproxy/addons/test_serverplayback.py b/test/mitmproxy/addons/test_serverplayback.py index 7cc5a5550..f7124a91d 100644 --- a/test/mitmproxy/addons/test_serverplayback.py +++ b/test/mitmproxy/addons/test_serverplayback.py @@ -1,6 +1,6 @@ from mitmproxy.test import tflow -from .. import tutils, mastertest +from .. import mastertest import mitmproxy.test.tutils from mitmproxy.addons import serverplayback diff --git a/test/mitmproxy/addons/test_state.py b/test/mitmproxy/addons/test_state.py index deb417f64..16e79e0d4 100644 --- a/test/mitmproxy/addons/test_state.py +++ b/test/mitmproxy/addons/test_state.py @@ -3,8 +3,6 @@ from mitmproxy import proxy from mitmproxy import master from mitmproxy.addons import state -from .. import tutils - class TestState: def test_duplicate_flow(self): diff --git a/test/mitmproxy/addons/test_stickyauth.py b/test/mitmproxy/addons/test_stickyauth.py index 4121507d1..b02bf1f50 100644 --- a/test/mitmproxy/addons/test_stickyauth.py +++ b/test/mitmproxy/addons/test_stickyauth.py @@ -1,6 +1,6 @@ from mitmproxy.test import tflow -from .. import tutils, mastertest +from .. import mastertest from mitmproxy.addons import stickyauth from mitmproxy import master from mitmproxy import options diff --git a/test/mitmproxy/addons/test_streambodies.py b/test/mitmproxy/addons/test_streambodies.py index 26f6fb594..afd2cc51b 100644 --- a/test/mitmproxy/addons/test_streambodies.py +++ b/test/mitmproxy/addons/test_streambodies.py @@ -1,6 +1,6 @@ from mitmproxy.test import tflow -from .. import tutils, mastertest +from .. import mastertest from mitmproxy import master from mitmproxy import options from mitmproxy import proxy diff --git a/test/mitmproxy/console/test_master.py b/test/mitmproxy/console/test_master.py index 78ee6175a..fe5520623 100644 --- a/test/mitmproxy/console/test_master.py +++ b/test/mitmproxy/console/test_master.py @@ -6,7 +6,7 @@ from mitmproxy.tools import console from mitmproxy import proxy from mitmproxy.tools.console import common -from .. import tutils, mastertest +from .. import mastertest class TestConsoleState: diff --git a/test/mitmproxy/mastertest.py b/test/mitmproxy/mastertest.py index 10c7fbc20..e3bb30691 100644 --- a/test/mitmproxy/mastertest.py +++ b/test/mitmproxy/mastertest.py @@ -2,7 +2,6 @@ import contextlib from mitmproxy.test import tflow -from . import tutils import mitmproxy.test.tutils from mitmproxy import master diff --git a/test/mitmproxy/protocol/test_http1.py b/test/mitmproxy/protocol/test_http1.py index a382867f6..5026bef18 100644 --- a/test/mitmproxy/protocol/test_http1.py +++ b/test/mitmproxy/protocol/test_http1.py @@ -2,7 +2,7 @@ from mitmproxy.test import tflow from mitmproxy.net.http import http1 from mitmproxy.net.tcp import TCPClient from mitmproxy.test.tutils import treq -from .. import tutils, tservers +from .. import tservers class TestHTTPFlow: diff --git a/test/mitmproxy/test_flow.py b/test/mitmproxy/test_flow.py index 6be2bf13f..7a9d09012 100644 --- a/test/mitmproxy/test_flow.py +++ b/test/mitmproxy/test_flow.py @@ -268,14 +268,6 @@ class TestState: 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): f = tflow.tflow() state.add_flow(f)