mirror of
https://github.com/Grasscutters/mitmproxy.git
synced 2025-02-02 00:05:27 +00:00
fix #2800
This commit is contained in:
parent
6dd336fcec
commit
f41d521ce5
@ -49,8 +49,9 @@ def format_dict(
|
|||||||
]
|
]
|
||||||
entries, where key is padded to a uniform width.
|
entries, where key is padded to a uniform width.
|
||||||
"""
|
"""
|
||||||
max_key_len = max(len(k) for k in d.keys())
|
|
||||||
max_key_len = min(max_key_len, KEY_MAX)
|
max_key_len = max((len(k) for k in d.keys()), default=0)
|
||||||
|
max_key_len = min((max_key_len, KEY_MAX), default=0)
|
||||||
for key, value in d.items():
|
for key, value in d.items():
|
||||||
if isinstance(key, bytes):
|
if isinstance(key, bytes):
|
||||||
key += b":"
|
key += b":"
|
||||||
|
@ -1 +1,17 @@
|
|||||||
# TODO: write tests
|
import pytest
|
||||||
|
from mitmproxy.contentviews import base
|
||||||
|
|
||||||
|
|
||||||
|
def test_format_dict():
|
||||||
|
d = {"one": "two", "three": "four"}
|
||||||
|
f_d = base.format_dict(d)
|
||||||
|
assert next(f_d)
|
||||||
|
|
||||||
|
d = {"adsfa": ""}
|
||||||
|
f_d = base.format_dict(d)
|
||||||
|
assert next(f_d)
|
||||||
|
|
||||||
|
d = {}
|
||||||
|
f_d = base.format_dict(d)
|
||||||
|
with pytest.raises(StopIteration):
|
||||||
|
next(f_d)
|
||||||
|
Loading…
Reference in New Issue
Block a user