Issue 31604: unittest.TestLoader().loadTestsFromTestCase(...) fails when adding test cases with the expectedFailure decorator (original) (raw)

How to reproduce:

Description: Adding the decorator @unittest.expectedFailure to a unittest.TestCase causes the TestLoader().loadTestsFromTestCase(...) to fail with the following output:

=============================================================== $ python2.7 mwe.py Traceback (most recent call last): File "/usr/lib/python2.7/runpy.py", line 174, in _run_module_as_main "main", fname, loader, pkg_name) File "/usr/lib/python2.7/runpy.py", line 72, in _run_code exec code in run_globals File "[...]/mwe.py", line 12, in tests = unittest.TestLoader().loadTestsFromTestCase(TestClassThatFails) File "/usr/lib/python2.7/unittest/loader.py", line 50, in loadTestsFromTestCase if issubclass(testCaseClass, suite.TestSuite): TypeError: issubclass() arg 1 must be a class

The error does only occur when adding the test manually to a test suite. Running unittest.main(), does not produce the error.

I can't reproduce the issue on 3.10, I believe it was fixed by this:

https://github.com/python/cpython/commit/c9b3ef2df06818f055e555c1d23e3ff2d5bf2d74

in particular:

2.7 won't be fixed, so closing.