diff options
author | Aldo Cortesi <aldo@nullcube.com> | 2016-12-11 17:04:19 +1300 |
---|---|---|
committer | Aldo Cortesi <aldo@nullcube.com> | 2016-12-12 07:39:59 +1300 |
commit | ca33bea296195211e63fc0dc56171b7873600618 (patch) | |
tree | 7337f4cb56fd538bd6c3926ce3005e8d1adb9603 /test | |
parent | c5717b17df8577205106351bfe8299ff79f1930b (diff) | |
download | mitmproxy-ca33bea296195211e63fc0dc56171b7873600618.tar.gz mitmproxy-ca33bea296195211e63fc0dc56171b7873600618.tar.bz2 mitmproxy-ca33bea296195211e63fc0dc56171b7873600618.zip |
Extend type checker validate Sequence specs
Diffstat (limited to 'test')
-rw-r--r-- | test/mitmproxy/utils/test_typecheck.py | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/test/mitmproxy/utils/test_typecheck.py b/test/mitmproxy/utils/test_typecheck.py index 85684df9..3ec74b20 100644 --- a/test/mitmproxy/utils/test_typecheck.py +++ b/test/mitmproxy/utils/test_typecheck.py @@ -26,6 +26,8 @@ def test_check_type(): typecheck.check_type("foo", 42, str) with pytest.raises(TypeError): typecheck.check_type("foo", None, str) + with pytest.raises(TypeError): + typecheck.check_type("foo", b"foo", str) def test_check_union(): @@ -44,5 +46,14 @@ def test_check_tuple(): typecheck.check_type("foo", (42, 42), typing.Tuple[int, str]) with pytest.raises(TypeError): typecheck.check_type("foo", ("42", 42), typing.Tuple[int, str]) - typecheck.check_type("foo", (42, "42"), typing.Tuple[int, str]) + + +def test_check_sequence(): + typecheck.check_type("foo", [10], typing.Sequence[int]) + with pytest.raises(TypeError): + typecheck.check_type("foo", ["foo"], typing.Sequence[int]) + with pytest.raises(TypeError): + typecheck.check_type("foo", [10, "foo"], typing.Sequence[int]) + with pytest.raises(TypeError): + typecheck.check_type("foo", [b"foo"], typing.Sequence[str]) |