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 <rep...@bugs.python.org>
<http://bugs.python.org/issue16748>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to