diff options
Diffstat (limited to 'test')
-rw-r--r-- | test/mitmproxy/tools/console/test_statusbar.py | 23 |
1 files changed, 11 insertions, 12 deletions
diff --git a/test/mitmproxy/tools/console/test_statusbar.py b/test/mitmproxy/tools/console/test_statusbar.py index 7b991890..108f238e 100644 --- a/test/mitmproxy/tools/console/test_statusbar.py +++ b/test/mitmproxy/tools/console/test_statusbar.py @@ -2,7 +2,6 @@ import pytest from mitmproxy import options from mitmproxy.tools.console import statusbar, master -from unittest import mock def test_statusbar(monkeypatch): @@ -40,23 +39,23 @@ def test_statusbar(monkeypatch): ("", [(None, ""), ("warn", "")]), (("info", "Line fits into statusbar"), [("info", "Line fits into statusbar"), ("warn", "")]), - ("Line doesn't fit into statusbar", [(None, "Line does..."), + ("Line doesn't fit into statusbar", [(None, "Line doesn'\u2026"), ("warn", "(more in eventlog)")]), (("alert", "Two lines.\nFirst fits"), [("alert", "Two lines."), ("warn", "(more in eventlog)")]), - ("Two long lines\nFirst doesn't fit", [(None, "Two long ..."), + ("Two long lines\nFirst doesn't fit", [(None, "Two long li\u2026"), ("warn", "(more in eventlog)")]) ]) -def test_prep_message(message, ready_message): - m = mock.Mock() - m.ui.get_cols_rows.return_value = (30, 30) +def test_shorten_message(message, ready_message): + o = options.Options() + m = master.ConsoleMaster(o) ab = statusbar.ActionBar(m) - assert ab.prep_message(message) == ready_message + assert ab.shorten_message(message, max_width=30) == ready_message -def test_prep_message_narrow(): - m = mock.Mock() - m.ui.get_cols_rows.return_value = (4, 4) +def test_shorten_message_narrow(): + o = options.Options() + m = master.ConsoleMaster(o) ab = statusbar.ActionBar(m) - prep_msg = ab.prep_message("error") - assert prep_msg == [(None, "..."), ("warn", "(more in eventlog)")] + shorten_msg = ab.shorten_message("error", max_width=4) + assert shorten_msg == [(None, "\u2026"), ("warn", "(more in eventlog)")] |