[issue16748] Make CPython test package discoverable

Chris Jerdonek report at bugs.python.org
Fri Jan 11 11:26:34 CET 2013


Chris Jerdonek added the comment:

As suggested in the previous comment, here is simple code to find candidates for test duplication (TestCase subclasses subclassing other TestCase classes):

def find_dupes(mod):
    objects = [getattr(mod, name) for name in sorted(dir(mod))]
    classes = [obj for obj in objects if isinstance(obj, type) and
               issubclass(obj, unittest.TestCase)]
    for c in classes:
        for d in classes:
            if c is not d and issubclass(d, c):
                print("%s: %s < %s" % (mod.__name__, c.__name__, d.__name__))

Out of curiosity, I ran a modified form of this against all test modules to find which ones fit this pattern and *already* rely on unittest discovery (i.e. don't have test_main()).  We might want to adjust these as well.  There were four: test_asyncore, test_configparser, test_heapq, test_ipaddress

----------

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue16748>
_______________________________________


More information about the Python-bugs-list mailing list