[issue17519] unittest should not try to run abstract classes

Nathaniel Manista report at bugs.python.org
Thu Mar 11 10:58:57 EST 2021


Nathaniel Manista <nathaniel at google.com> added the comment:

In the years since this was considered and declined, I wonder if the facts have changed sufficiently to make it now worth doing?

I often find myself writing TestCases for interfaces, and those define test_* methods that call the interface under test, but of course my TestCase needs to be abstract because I'm only testing an interface and not a concrete implementation of that interface. It's also the case when I'm writing this kind of test that I wish to use a type-checker, and if I can have my abstract TestCase inherit from unittest.TestCase, that will satisfy my type-checker's questions about why I believe my TestCase has all kinds of assert* methods defined that it doesn't otherwise see.

I currently have the impression that if this is cheap enough to do, it may be worth doing just for the ergonomics alone? It mightn't make anything impossible become possible to do, but I forecast that it would make something difficult to do much more straightforward to do.

(I remain a fan of the all-powerful load_tests protocol, but... often it's nice to escape all the responsibility that comes with use of it.)

----------

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue17519>
_______________________________________


More information about the Python-bugs-list mailing list