diff options
author | Maximilian Hils <git@maximilianhils.com> | 2018-01-05 16:09:43 +0100 |
---|---|---|
committer | Maximilian Hils <git@maximilianhils.com> | 2018-01-05 16:45:50 +0100 |
commit | 2e2daeed892f46622ae004ba7650cde798de4a5f (patch) | |
tree | 82eeecc0d983ca1d8e3a5754dc5ed9c4f3669123 /test/mitmproxy/tools/console/test_common.py | |
parent | 9b03ab59ef2f3c3f40b0db0d204b00d819fcc5f5 (diff) | |
download | mitmproxy-2e2daeed892f46622ae004ba7650cde798de4a5f.tar.gz mitmproxy-2e2daeed892f46622ae004ba7650cde798de4a5f.tar.bz2 mitmproxy-2e2daeed892f46622ae004ba7650cde798de4a5f.zip |
refactor common.format_keyvals
the semantics here were really quite unclear,
now it is hopefully a bit more obvious what's happening.
Once we are Python 3.6+ exclusively, we may consider changing
the signature to accept a (order-preserving) dict instead of a list.
Diffstat (limited to 'test/mitmproxy/tools/console/test_common.py')
-rw-r--r-- | test/mitmproxy/tools/console/test_common.py | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/test/mitmproxy/tools/console/test_common.py b/test/mitmproxy/tools/console/test_common.py index a996c010..72438c49 100644 --- a/test/mitmproxy/tools/console/test_common.py +++ b/test/mitmproxy/tools/console/test_common.py @@ -1,3 +1,5 @@ +import urwid + from mitmproxy.test import tflow from mitmproxy.tools.console import common @@ -7,3 +9,26 @@ def test_format_flow(): assert common.format_flow(f, True) assert common.format_flow(f, True, hostheader=True) assert common.format_flow(f, True, extended=True) + + +def test_format_keyvals(): + assert common.format_keyvals( + [ + ("aa", "bb"), + ("cc", "dd"), + ("ee", None), + ] + ) + wrapped = urwid.BoxAdapter( + urwid.ListBox( + urwid.SimpleFocusListWalker( + common.format_keyvals([("foo", "bar")]) + ) + ), 1 + ) + assert wrapped.render((30, )) + assert common.format_keyvals( + [ + ("aa", wrapped) + ] + ) |