Skip to content
Prev Previous commit
Next Next commit
more tests
  • Loading branch information
hauntsaninja
hauntsaninja committed Mar 13, 2022
commit 6e7644165f71c20d0f2ebd38354ec8298d840214
15 changes: 13 additions & 2 deletions Lib/test/test_typing.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,8 +99,19 @@ def test_errors(self):
Any[int] # Any is not a generic type.

def test_can_subclass(self):
class X(Any): pass
X()
class Mock(Any): pass
self.assertTrue(issubclass(Mock, Any))
self.assertIsInstance(Mock(), Mock)

class Something: pass
self.assertFalse(issubclass(Something, Any))
self.assertNotIsInstance(Something(), Any)

class MockSomething(Something, Any): pass
self.assertTrue(issubclass(MockSomething, Any))
ms = MockSomething()
self.assertIsInstance(ms, Mock)
self.assertIsInstance(ms, Something)

def test_cannot_instantiate(self):
with self.assertRaises(TypeError):
Expand Down