From 9687d676012379f5875331423fbbbe33fcd63434 Mon Sep 17 00:00:00 2001 From: Matthew Shao Date: Wed, 14 Jun 2017 07:44:00 +0800 Subject: Add test for typespec_to_str. --- test/mitmproxy/utils/test_typecheck.py | 8 ++++++++ 1 file changed, 8 insertions(+) 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) -- cgit v1.2.3