diff options
author | Miroslav <ttahabatt@gmail.com> | 2018-03-03 22:12:56 +0200 |
---|---|---|
committer | Miroslav <ttahabatt@gmail.com> | 2018-03-03 22:12:56 +0200 |
commit | 237320a539c90411bcc27a40a6ae30fb800cda16 (patch) | |
tree | 2c728e05f5c0a746c79a49c7b810d040c63727c7 /test | |
parent | 63f0a712d8519401240b7f8ca5b79b363204631f (diff) | |
download | mitmproxy-237320a539c90411bcc27a40a6ae30fb800cda16.tar.gz mitmproxy-237320a539c90411bcc27a40a6ae30fb800cda16.tar.bz2 mitmproxy-237320a539c90411bcc27a40a6ae30fb800cda16.zip |
Minor fixes.
Renaming prep_message method to shorten_message.
Docstring.
\u2026 instead of ....
max_width parameter.
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)")] |