Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Remove misleading comment, TestCase->BaseTestCase
  • Loading branch information
zware committed Apr 19, 2016
commit b1aa749d0a8cf9462525a8166339dd8448c6f48b
42 changes: 20 additions & 22 deletions src/test_typing.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import pickle
import re
import sys
from unittest import TestCase as _TestCase, main, skipUnless
from unittest import TestCase, main, skipUnless

from typing import Any
from typing import TypeVar, AnyStr
Expand All @@ -20,9 +20,7 @@
import typing


class TestCase(_TestCase):

# vanilla TestCase doesn't have assert*Subclass, see bugs.python.org/14819
class BaseTestCase(TestCase):

def assertIsSubclass(self, cls, class_or_tuple, msg=None):
if not issubclass(cls, class_or_tuple):
Expand Down Expand Up @@ -55,7 +53,7 @@ class ManagingFounder(Manager, Founder):
pass


class AnyTests(TestCase):
class AnyTests(BaseTestCase):

def test_any_instance_type_error(self):
with self.assertRaises(TypeError):
Expand Down Expand Up @@ -119,7 +117,7 @@ def test_any_is_subclass(self):
typing.IO[Any]


class TypeVarTests(TestCase):
class TypeVarTests(BaseTestCase):

def test_basic_plain(self):
T = TypeVar('T')
Expand Down Expand Up @@ -224,7 +222,7 @@ def test_bound_errors(self):
TypeVar('X', str, float, bound=Employee)


class UnionTests(TestCase):
class UnionTests(BaseTestCase):

def test_basics(self):
u = Union[int, float]
Expand Down Expand Up @@ -340,7 +338,7 @@ def test_union_str_pattern(self):
A


class TypeVarUnionTests(TestCase):
class TypeVarUnionTests(BaseTestCase):

def test_simpler(self):
A = TypeVar('A', int, str, float)
Expand All @@ -366,7 +364,7 @@ def test_var_union(self):
self.assertIsSubclass(float, TU)


class TupleTests(TestCase):
class TupleTests(BaseTestCase):

def test_basics(self):
self.assertTrue(issubclass(Tuple[int, str], Tuple))
Expand Down Expand Up @@ -421,7 +419,7 @@ def test_errors(self):
issubclass(42, Tuple[int])


class CallableTests(TestCase):
class CallableTests(BaseTestCase):

def test_self_subclass(self):
self.assertTrue(issubclass(Callable[[int], int], Callable))
Expand Down Expand Up @@ -532,7 +530,7 @@ def get(self, key: str, default=None):
return default


class ProtocolTests(TestCase):
class ProtocolTests(BaseTestCase):

def test_supports_int(self):
self.assertIsSubclass(int, typing.SupportsInt)
Expand Down Expand Up @@ -582,7 +580,7 @@ def test_protocol_instance_type_error(self):
isinstance(0, typing.SupportsAbs)


class GenericTests(TestCase):
class GenericTests(BaseTestCase):

def test_basics(self):
X = SimpleMapping[str, Any]
Expand Down Expand Up @@ -809,7 +807,7 @@ class D(C):
D[T]


class VarianceTests(TestCase):
class VarianceTests(BaseTestCase):

def test_invariance(self):
# Because of invariance, List[subclass of X] is not a subclass
Expand Down Expand Up @@ -855,7 +853,7 @@ def test_covariance_mapping(self):
typing.Mapping[Manager, Manager])


class CastTests(TestCase):
class CastTests(BaseTestCase):

def test_basics(self):
self.assertEqual(cast(int, 42), 42)
Expand All @@ -873,7 +871,7 @@ def test_errors(self):
cast('hello', 42)


class ForwardRefTests(TestCase):
class ForwardRefTests(BaseTestCase):

def test_basics(self):

Expand Down Expand Up @@ -1035,7 +1033,7 @@ def test_default_globals(self):
self.assertEqual(hints, {'a': ns['C'], 'return': ns['D']})


class OverloadTests(TestCase):
class OverloadTests(BaseTestCase):

def test_overload_exists(self):
from typing import overload
Expand Down Expand Up @@ -1101,7 +1099,7 @@ def __anext__(self) -> T_a:
exec(PY35_TESTS)


class CollectionsAbcTests(TestCase):
class CollectionsAbcTests(BaseTestCase):

def test_hashable(self):
self.assertIsInstance(42, typing.Hashable)
Expand Down Expand Up @@ -1341,7 +1339,7 @@ def __len__(self):
self.assertEqual(len(MMB[KT, VT]()), 0)


class OtherABCTests(TestCase):
class OtherABCTests(BaseTestCase):

@skipUnless(hasattr(typing, 'ContextManager'),
'requires typing.ContextManager')
Expand All @@ -1356,7 +1354,7 @@ def manager():
self.assertNotIsInstance(42, typing.ContextManager)


class NamedTupleTests(TestCase):
class NamedTupleTests(BaseTestCase):

def test_basics(self):
Emp = NamedTuple('Emp', [('name', str), ('id', int)])
Expand All @@ -1383,7 +1381,7 @@ def test_pickle(self):
self.assertEqual(jane2, jane)


class IOTests(TestCase):
class IOTests(BaseTestCase):

def test_io(self):

Expand Down Expand Up @@ -1418,7 +1416,7 @@ def test_io_submodule(self):
self.assertEqual(__name__, 'typing.io')


class RETests(TestCase):
class RETests(BaseTestCase):
# Much of this is really testing _TypeAlias.

def test_basics(self):
Expand Down Expand Up @@ -1485,7 +1483,7 @@ class A(typing.Match):
"A type alias cannot be subclassed")


class AllTests(TestCase):
class AllTests(BaseTestCase):
"""Tests for __all__."""

def test_all(self):
Expand Down