summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_inspect.py
diff options
context:
space:
mode:
Diffstat (limited to 'Lib/test/test_inspect.py')
-rw-r--r--Lib/test/test_inspect.py24
1 files changed, 24 insertions, 0 deletions
diff --git a/Lib/test/test_inspect.py b/Lib/test/test_inspect.py
index cfea281..37e4511 100644
--- a/Lib/test/test_inspect.py
+++ b/Lib/test/test_inspect.py
@@ -232,6 +232,30 @@ class TestPredicates(IsTestBase):
self.assertFalse(inspect.isabstract(int))
self.assertFalse(inspect.isabstract(5))
+ def test_isabstract_during_init_subclass(self):
+ from abc import ABCMeta, abstractmethod
+ isabstract_checks = []
+ class AbstractChecker(metaclass=ABCMeta):
+ def __init_subclass__(cls):
+ isabstract_checks.append(inspect.isabstract(cls))
+ class AbstractClassExample(AbstractChecker):
+ @abstractmethod
+ def foo(self):
+ pass
+ class ClassExample(AbstractClassExample):
+ def foo(self):
+ pass
+ self.assertEqual(isabstract_checks, [True, False])
+
+ isabstract_checks.clear()
+ class AbstractChild(AbstractClassExample):
+ pass
+ class AbstractGrandchild(AbstractChild):
+ pass
+ class ConcreteGrandchild(ClassExample):
+ pass
+ self.assertEqual(isabstract_checks, [True, True, False])
+
class TestInterpreterStack(IsTestBase):
def __init__(self, *args, **kwargs):