'regression test for https://github.com/mitmproxy/mitmproxy/issues/1605'

def test_intercept(self):

    m = self.mkmaster(intercept='~b    bar')
    f = tflow.tflow(req=tutils.treq(content='foo'))
    m.addons.handle_lifecycle('request', f)
    assert (not m.view[0].intercepted)
    f = tflow.tflow(req=tutils.treq(content='bar'))
    m.addons.handle_lifecycle('request', f)
    assert m.view[1].intercepted
    f = tflow.tflow(resp=tutils.tresp(content='bar'))
    m.addons.handle_lifecycle('request', f)
    assert m.view[2].intercepted
