aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatthew Shao <me@matshao.com>2017-06-14 07:44:00 +0800
committerMatthew Shao <me@matshao.com>2017-06-14 07:44:00 +0800
commit9687d676012379f5875331423fbbbe33fcd63434 (patch)
treec928154aa37327725638f7a78f8d5de419a51865
parent1177e6d90777da92c72a1e88de93312f2ca1e6ff (diff)
downloadmitmproxy-9687d676012379f5875331423fbbbe33fcd63434.tar.gz
mitmproxy-9687d676012379f5875331423fbbbe33fcd63434.tar.bz2
mitmproxy-9687d676012379f5875331423fbbbe33fcd63434.zip
Add test for typespec_to_str.
-rw-r--r--test/mitmproxy/utils/test_typecheck.py8
1 files changed, 8 insertions, 0 deletions
diff --git a/test/mitmproxy/utils/test_typecheck.py b/test/mitmproxy/utils/test_typecheck.py
index fe33070e..8e4198da 100644
--- a/test/mitmproxy/utils/test_typecheck.py
+++ b/test/mitmproxy/utils/test_typecheck.py
@@ -111,3 +111,11 @@ def test_check_command_type():
m.__str__ = lambda self: "typing.Union"
m.__union_params__ = (int,)
assert not typecheck.check_command_type([22], m)
+
+
+def test_typesec_to_str():
+ assert(typecheck.typespec_to_str(str)) == "str"
+ assert(typecheck.typespec_to_str(typing.Sequence[str])) == "Sequence"
+ assert(typecheck.typespec_to_str(typing.Optional[str])) == "Union"
+ with pytest.raises(NotImplementedError):
+ typecheck.typespec_to_str(dict)