From 0929e74b4e82e3ee9ba1d6ddb7a54a68240a4282 Mon Sep 17 00:00:00 2001 From: Maximilian Hils Date: Wed, 28 Dec 2016 13:39:27 +0100 Subject: fix compat with Python 3.5.0 --- test/mitmproxy/utils/test_typecheck.py | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'test') diff --git a/test/mitmproxy/utils/test_typecheck.py b/test/mitmproxy/utils/test_typecheck.py index 3ec74b20..75c932e5 100644 --- a/test/mitmproxy/utils/test_typecheck.py +++ b/test/mitmproxy/utils/test_typecheck.py @@ -1,5 +1,6 @@ import typing +import mock import pytest from mitmproxy.utils import typecheck @@ -57,3 +58,11 @@ def test_check_sequence(): typecheck.check_type("foo", [10, "foo"], typing.Sequence[int]) with pytest.raises(TypeError): typecheck.check_type("foo", [b"foo"], typing.Sequence[str]) + with pytest.raises(TypeError): + typecheck.check_type("foo", "foo", typing.Sequence[str]) + + # Python 3.5.0 only defines __parameters__ + m = mock.Mock() + m.__str__ = lambda self: "typing.Sequence" + m.__parameters__ = (int,) + typecheck.check_type("foo", [10], m) -- cgit v1.2.3 From eab360a02b13b0dcc659546ddde383cc5a5b88bb Mon Sep 17 00:00:00 2001 From: Maximilian Hils Date: Wed, 28 Dec 2016 14:21:19 +0100 Subject: fix IO type checking --- test/mitmproxy/utils/test_typecheck.py | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'test') diff --git a/test/mitmproxy/utils/test_typecheck.py b/test/mitmproxy/utils/test_typecheck.py index 75c932e5..0ed440eb 100644 --- a/test/mitmproxy/utils/test_typecheck.py +++ b/test/mitmproxy/utils/test_typecheck.py @@ -1,7 +1,9 @@ +import io import typing import mock import pytest + from mitmproxy.utils import typecheck @@ -66,3 +68,9 @@ def test_check_sequence(): m.__str__ = lambda self: "typing.Sequence" m.__parameters__ = (int,) typecheck.check_type("foo", [10], m) + + +def test_check_io(): + typecheck.check_type("foo", io.StringIO(), typing.IO[str]) + with pytest.raises(TypeError): + typecheck.check_type("foo", "foo", typing.IO[str]) -- cgit v1.2.3