[issue31604] unittest.TestLoader().loadTestsFromTestCase(...) fails when adding test cases with the expectedFailure decorator

Erasmus Cedernaes report at bugs.python.org
Wed Sep 27 04:16:44 EDT 2017


New submission from Erasmus Cedernaes <emanuelen5 at gmail.com>:

How to reproduce:
* Run the attached file with Python 2.7 without any modifications. This will produce an error, as described below.
* Uncomment line 2 (the decorator @unittest.expectedFailure) and run the file with Python 2.7. This will not produce an error.

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 <module>
    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.

----------
components: Tests
files: mwe.py
messages: 303112
nosy: Erasmus Cedernaes
priority: normal
severity: normal
status: open
title: unittest.TestLoader().loadTestsFromTestCase(...) fails when adding test cases with the expectedFailure decorator
type: crash
versions: Python 2.7
Added file: https://bugs.python.org/file47170/mwe.py

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


More information about the Python-bugs-list mailing list