<commit_before>import mitmproxy.tools.console.flowlist as flowlist
from mitmproxy.tools import console
from mitmproxy import proxy
from mitmproxy import options
from .. import tservers
import pytest
from unittest import mock


class UrlError(Exception):
    pass


def mock_log(message):
    if "Invalid URL" in message:
        raise UrlError(message)


class TestFlowlist(tservers.MasterTest):
    def mkmaster(self, **opts):
        if "verbosity" not in opts:
            opts["verbosity"] = 1
        o = options.Options(**opts)
        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, test_func):
        m = self.mkmaster()
        x = flowlist.FlowListBox(m)
        with pytest.raises(UrlError):
            x.new_request("nonexistent url", "GET")<commit_msg>Update test_flowlist.py<commit_after>import mitmproxy.tools.console.flowlist as flowlist
from mitmproxy.tools import console
from mitmproxy import proxy
from mitmproxy import options
from .. import tservers
import pytest
from unittest import mock as Mock


class TestFlowlist(tservers.MasterTest):
    def mkmaster(self, **opts):
        if "verbosity" not in opts:
            opts["verbosity"] = 1
        o = options.Options(**opts)
        return console.master.ConsoleMaster(o, proxy.DummyServer())

    def test_new_request(self):
        m = self.mkmaster()
        x = flowlist.FlowListBox(m)
        with Mock.patch('mitmproxy.tools.console.signals.status_message.send') as mock:
            x.new_request("nonexistent url", "GET")
        mock.assert_called_once_with(message = "Invalid URL: No hostname given")
{'fraction_non_alphanumeric': 0.09727851766068327, 'fraction_numerical': 0.0011580775911986102, 'mean_word_length': 3.4883116883116885, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4925361', 'n_tokens_mistral': 525, 'n_tokens_neox': 521, 'n_words': 132}