Add tests for qutebrowser.utils.typing
This commit is contained in:
parent
6ed9b6b13f
commit
c0d044447d
@ -67,5 +67,5 @@ class FakeUnion(metaclass=FakeUnionMeta):
|
||||
|
||||
try:
|
||||
from typing import Union
|
||||
except ImportError:
|
||||
except ImportError: # pragma: no cover
|
||||
Union = FakeUnion
|
||||
|
@ -136,6 +136,8 @@ PERFECT_FILES = [
|
||||
'qutebrowser/utils/jinja.py'),
|
||||
('tests/unit/utils/test_error.py',
|
||||
'qutebrowser/utils/error.py'),
|
||||
('tests/unit/utils/test_typing.py',
|
||||
'qutebrowser/utils/typing.py'),
|
||||
]
|
||||
|
||||
|
||||
|
44
tests/unit/utils/test_typing.py
Normal file
44
tests/unit/utils/test_typing.py
Normal file
@ -0,0 +1,44 @@
|
||||
# Copyright 2016 Florian Bruhin (The Compiler) <mail@qutebrowser.org>
|
||||
# vim: ft=python fileencoding=utf-8 sts=4 sw=4 et:
|
||||
|
||||
#
|
||||
# qutebrowser is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation, either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# qutebrowser is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with qutebrowser. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
"""Tests for qutebrowser.utils.typing."""
|
||||
|
||||
import pytest
|
||||
|
||||
from qutebrowser.utils import typing
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def pytyping():
|
||||
"""A fixture to get the python 3.5+ typing module."""
|
||||
pytyping = pytest.importorskip('typing')
|
||||
return pytyping
|
||||
|
||||
|
||||
class TestUnion:
|
||||
|
||||
def test_python_subclass(self, pytyping):
|
||||
assert issubclass(pytyping.Union[str, int], pytyping.Union)
|
||||
|
||||
def test_qute_subclass(self):
|
||||
assert issubclass(typing.FakeUnion[str, int], typing.FakeUnion)
|
||||
|
||||
def test_python_params(self, pytyping):
|
||||
assert pytyping.Union[str, int].__union_params__ == (str, int)
|
||||
|
||||
def test_qute_params(self):
|
||||
assert typing.FakeUnion[str, int].__union_params__ == (str, int)
|
Loading…
Reference in New Issue
Block a user