diff options
author | Maximilian Hils <git@maximilianhils.com> | 2016-12-28 15:35:07 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2016-12-28 15:35:07 +0100 |
commit | 973406f327ceb488d4fa269b57d1e4f342e59d2c (patch) | |
tree | 142f7777a79de03845ff715237d8164ffd5ca325 /test | |
parent | 8185cf27243a7c982ff4c3151045b3d494396740 (diff) | |
parent | eab360a02b13b0dcc659546ddde383cc5a5b88bb (diff) | |
download | mitmproxy-973406f327ceb488d4fa269b57d1e4f342e59d2c.tar.gz mitmproxy-973406f327ceb488d4fa269b57d1e4f342e59d2c.tar.bz2 mitmproxy-973406f327ceb488d4fa269b57d1e4f342e59d2c.zip |
Merge pull request #1896 from mhils/3.5.0-compat
Fix compat with Python 3.5.0
Diffstat (limited to 'test')
-rw-r--r-- | test/mitmproxy/utils/test_typecheck.py | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/test/mitmproxy/utils/test_typecheck.py b/test/mitmproxy/utils/test_typecheck.py index 3ec74b20..0ed440eb 100644 --- a/test/mitmproxy/utils/test_typecheck.py +++ b/test/mitmproxy/utils/test_typecheck.py @@ -1,6 +1,9 @@ +import io import typing +import mock import pytest + from mitmproxy.utils import typecheck @@ -57,3 +60,17 @@ 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) + + +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]) |