diff options
Diffstat (limited to 'test')
-rw-r--r-- | test/mitmproxy/test_contentview.py | 8 | ||||
-rw-r--r-- | test/mitmproxy/test_utils.py | 15 | ||||
-rw-r--r-- | test/netlib/test_human.py | 9 | ||||
-rw-r--r-- | test/pathod/test_pathod_cmdline.py | 5 | ||||
-rw-r--r-- | test/pathod/test_utils.py | 5 |
5 files changed, 22 insertions, 20 deletions
diff --git a/test/mitmproxy/test_contentview.py b/test/mitmproxy/test_contentview.py index 9142bdad..48d6c307 100644 --- a/test/mitmproxy/test_contentview.py +++ b/test/mitmproxy/test_contentview.py @@ -1,3 +1,5 @@ +import json + from mitmproxy.exceptions import ContentViewException from netlib.http import Headers from netlib.odict import ODict @@ -274,3 +276,9 @@ if cv.ViewProtobuf.is_available(): def test_get_by_shortcut(): assert cv.get_by_shortcut("h") + + +def test_pretty_json(): + s = json.dumps({"foo": 1}) + assert cv.pretty_json(s) + assert not cv.pretty_json("moo") diff --git a/test/mitmproxy/test_utils.py b/test/mitmproxy/test_utils.py index c01b5f2a..79b72eec 100644 --- a/test/mitmproxy/test_utils.py +++ b/test/mitmproxy/test_utils.py @@ -1,29 +1,14 @@ -import json from mitmproxy import utils from . import tutils utils.CERT_SLEEP_TIME = 0 -def test_format_timestamp(): - assert utils.format_timestamp(utils.timestamp()) - - -def test_format_timestamp_with_milli(): - assert utils.format_timestamp_with_milli(utils.timestamp()) - - def test_pkg_data(): assert utils.pkg_data.path("console") tutils.raises("does not exist", utils.pkg_data.path, "nonexistent") -def test_pretty_json(): - s = json.dumps({"foo": 1}) - assert utils.pretty_json(s) - assert not utils.pretty_json("moo") - - def test_LRUCache(): cache = utils.LRUCache(2) diff --git a/test/netlib/test_human.py b/test/netlib/test_human.py index 2a5c2a85..bb97dc54 100644 --- a/test/netlib/test_human.py +++ b/test/netlib/test_human.py @@ -1,6 +1,15 @@ +import time from netlib import human, tutils +def test_format_timestamp(): + assert human.format_timestamp(time.time()) + + +def test_format_timestamp_with_milli(): + assert human.format_timestamp_with_milli(time.time()) + + def test_parse_size(): assert human.parse_size("0") == 0 assert human.parse_size("0b") == 0 diff --git a/test/pathod/test_pathod_cmdline.py b/test/pathod/test_pathod_cmdline.py index 3c0918ef..18d54c82 100644 --- a/test/pathod/test_pathod_cmdline.py +++ b/test/pathod/test_pathod_cmdline.py @@ -3,6 +3,11 @@ import tutils import mock +def test_parse_anchor_spec(): + assert cmdline.parse_anchor_spec("foo=200") == ("foo", "200") + assert cmdline.parse_anchor_spec("foo") is None + + @mock.patch("argparse.ArgumentParser.error") def test_pathod(perror): assert cmdline.args_pathod(["pathod"]) diff --git a/test/pathod/test_utils.py b/test/pathod/test_utils.py index a46a523a..2bb82fe7 100644 --- a/test/pathod/test_utils.py +++ b/test/pathod/test_utils.py @@ -11,10 +11,5 @@ def test_membool(): assert m.v == 2 -def test_parse_anchor_spec(): - assert utils.parse_anchor_spec("foo=200") == ("foo", "200") - assert utils.parse_anchor_spec("foo") is None - - def test_data_path(): tutils.raises(ValueError, utils.data.path, "nonexistent") |