diff options
Diffstat (limited to 'test')
-rw-r--r-- | test/mitmproxy/test_utils.py | 25 | ||||
-rw-r--r-- | test/netlib/test_human.py | 31 | ||||
-rw-r--r-- | test/netlib/test_utils.py | 7 | ||||
-rw-r--r-- | test/pathod/test_utils.py | 7 |
4 files changed, 31 insertions, 39 deletions
diff --git a/test/mitmproxy/test_utils.py b/test/mitmproxy/test_utils.py index db7dec4a..2af7a332 100644 --- a/test/mitmproxy/test_utils.py +++ b/test/mitmproxy/test_utils.py @@ -43,21 +43,6 @@ def test_pretty_json(): assert not utils.pretty_json("moo") -def test_pretty_duration(): - assert utils.pretty_duration(0.00001) == "0ms" - assert utils.pretty_duration(0.0001) == "0ms" - assert utils.pretty_duration(0.001) == "1ms" - assert utils.pretty_duration(0.01) == "10ms" - assert utils.pretty_duration(0.1) == "100ms" - assert utils.pretty_duration(1) == "1.00s" - assert utils.pretty_duration(10) == "10.0s" - assert utils.pretty_duration(100) == "100s" - assert utils.pretty_duration(1000) == "1000s" - assert utils.pretty_duration(10000) == "10000s" - assert utils.pretty_duration(1.123) == "1.12s" - assert utils.pretty_duration(0.123) == "123ms" - - def test_LRUCache(): cache = utils.LRUCache(2) @@ -89,13 +74,3 @@ def test_LRUCache(): assert len(cache.cacheList) == 2 assert len(cache.cache) == 2 - - -def test_parse_size(): - assert not utils.parse_size("") - assert utils.parse_size("1") == 1 - assert utils.parse_size("1k") == 1024 - assert utils.parse_size("1m") == 1024**2 - assert utils.parse_size("1g") == 1024**3 - tutils.raises(ValueError, utils.parse_size, "1f") - tutils.raises(ValueError, utils.parse_size, "ak") diff --git a/test/netlib/test_human.py b/test/netlib/test_human.py new file mode 100644 index 00000000..3a445c0b --- /dev/null +++ b/test/netlib/test_human.py @@ -0,0 +1,31 @@ +from netlib import human, tutils + +def test_parse_size(): + assert human.parse_size("1") == 1 + assert human.parse_size("1k") == 1024 + assert human.parse_size("1m") == 1024**2 + assert human.parse_size("1g") == 1024**3 + tutils.raises(ValueError, human.parse_size, "1f") + tutils.raises(ValueError, human.parse_size, "ak") + + +def test_pretty_size(): + assert human.pretty_size(100) == "100B" + assert human.pretty_size(1024) == "1kB" + assert human.pretty_size(1024 + (1024 / 2.0)) == "1.5kB" + assert human.pretty_size(1024 * 1024) == "1MB" + + +def test_pretty_duration(): + assert human.pretty_duration(0.00001) == "0ms" + assert human.pretty_duration(0.0001) == "0ms" + assert human.pretty_duration(0.001) == "1ms" + assert human.pretty_duration(0.01) == "10ms" + assert human.pretty_duration(0.1) == "100ms" + assert human.pretty_duration(1) == "1.00s" + assert human.pretty_duration(10) == "10.0s" + assert human.pretty_duration(100) == "100s" + assert human.pretty_duration(1000) == "1000s" + assert human.pretty_duration(10000) == "10000s" + assert human.pretty_duration(1.123) == "1.12s" + assert human.pretty_duration(0.123) == "123ms" diff --git a/test/netlib/test_utils.py b/test/netlib/test_utils.py index b3cc9a0b..e13029cb 100644 --- a/test/netlib/test_utils.py +++ b/test/netlib/test_utils.py @@ -30,13 +30,6 @@ def test_clean_bin(): assert utils.clean_bin(u"\u2605") == u"\u2605" -def test_pretty_size(): - assert utils.pretty_size(100) == "100B" - assert utils.pretty_size(1024) == "1kB" - assert utils.pretty_size(1024 + (1024 / 2.0)) == "1.5kB" - assert utils.pretty_size(1024 * 1024) == "1MB" - - def test_safe_subn(): assert utils.safe_subn("foo", u"bar", "\xc2foo") diff --git a/test/pathod/test_utils.py b/test/pathod/test_utils.py index 8026a576..ab4abbae 100644 --- a/test/pathod/test_utils.py +++ b/test/pathod/test_utils.py @@ -13,13 +13,6 @@ def test_membool(): assert m.v == 2 -def test_parse_size(): - assert utils.parse_size("100") == 100 - assert utils.parse_size("100k") == 100 * 1024 - tutils.raises("invalid size spec", utils.parse_size, "foo") - tutils.raises("invalid size spec", utils.parse_size, "100kk") - - def test_parse_anchor_spec(): assert utils.parse_anchor_spec("foo=200") == ("foo", "200") assert utils.parse_anchor_spec("foo") is None |