I’m curious if anyone has a reason why we shouldn’t change unittest to understand abc classes? Currently this example fails:
import abc
import unittest
class Mixin(unittest.TestCase, abc.ABC):
@abc.abstractmethod
def make_backend(self):
...
def test_it(self):
assert 1 == 2
unittest tries to instantiate the TestCase class, which it cannot do:
... etc ...
File "/usr/local/pyenv/pyenv/versions/3.12.4/lib/python3.12/unittest/suite.py", line 24, in __init__
self.addTests(tests)
File "/usr/local/pyenv/pyenv/versions/3.12.4/lib/python3.12/unittest/suite.py", line 57, in addTests
for test in tests:
TypeError: Can't instantiate abstract class Mixin without an implementation for abstract method 'make_backend'
Since the code as presented is now an error, wouldn’t it be better to update unittest to not attempt to instantiate classes that can’t be instantiated?