mirror of
https://github.com/Grasscutters/mitmproxy.git
synced 2024-11-23 08:11:00 +00:00
Update test_flowlist.py
This commit is contained in:
parent
26a17a3d82
commit
a52d8c1dab
@ -4,16 +4,7 @@ from mitmproxy import proxy
|
|||||||
from mitmproxy import options
|
from mitmproxy import options
|
||||||
from .. import tservers
|
from .. import tservers
|
||||||
import pytest
|
import pytest
|
||||||
from unittest import mock
|
from unittest import mock as Mock
|
||||||
|
|
||||||
|
|
||||||
class UrlError(Exception):
|
|
||||||
pass
|
|
||||||
|
|
||||||
|
|
||||||
def mock_log(message):
|
|
||||||
if "Invalid URL" in message:
|
|
||||||
raise UrlError(message)
|
|
||||||
|
|
||||||
|
|
||||||
class TestFlowlist(tservers.MasterTest):
|
class TestFlowlist(tservers.MasterTest):
|
||||||
@ -23,9 +14,9 @@ class TestFlowlist(tservers.MasterTest):
|
|||||||
o = options.Options(**opts)
|
o = options.Options(**opts)
|
||||||
return console.master.ConsoleMaster(o, proxy.DummyServer())
|
return console.master.ConsoleMaster(o, proxy.DummyServer())
|
||||||
|
|
||||||
@mock.patch('mitmproxy.tools.console.signals.status_message.send', side_effect = mock_log)
|
def test_new_request(self):
|
||||||
def test_new_request(self, test_func):
|
|
||||||
m = self.mkmaster()
|
m = self.mkmaster()
|
||||||
x = flowlist.FlowListBox(m)
|
x = flowlist.FlowListBox(m)
|
||||||
with pytest.raises(UrlError):
|
with Mock.patch('mitmproxy.tools.console.signals.status_message.send') as mock:
|
||||||
x.new_request("nonexistent url", "GET")
|
x.new_request("nonexistent url", "GET")
|
||||||
|
mock.assert_called_once_with(message = "Invalid URL: No hostname given")
|
||||||
|
Loading…
Reference in New Issue
Block a user