Bug report
Bug description:
As reported in Discourse, loading a TestCase-derived subclass that is also an abstract base class like the following:
import unittest from abc import ABC, abstractmethod class FooBase(unittest.TestCase, ABC): @abstractmethod def test(self): ... class Foo(FooBase): def test(self): pass unittest.main()
would currently result in:
TypeError: Can't instantiate abstract class FooBase without an implementation for abstract method 'test'
We should make the unittest loaders avoid loading such test cases and methods from them.
CPython versions tested on:
3.12, CPython main branch
Operating systems tested on:
Linux, Windows
Linked PRs
- gh-120665: make unittest loaders avoid loading test cases that are abstract base classes #120666
- [3.13] gh-120665: make unittest loaders avoid loading test cases that are abstract base classes (GH-120666) #151599
- [3.14] gh-120665: make unittest loaders avoid loading test cases that are abstract base classes (GH-120666) #151600
- [3.15] gh-120665: make unittest loaders avoid loading test cases that are abstract base classes (GH-120666) #151601