[issue23142] Integration of unittest.FunctionTestCase with automatic discovery and loading

Martin Panter report at bugs.python.org
Thu Jan 1 08:58:44 CET 2015


New submission from Martin Panter:

It is not clear how you are meant to use unittest.FunctionTestCase with automatic test running. Unless a simple way to do this already exists, I wonder if it would be okay to automatically discover and run predefined test instances, such as the "test_module.testcase" object in my example module.

Currently the “testcase” object is ignored by the automatic test discovery. Also, attempting to manually run it results in

$ python -m unittest test_module.testcase
[. . .]
TypeError: calling unittest.case.FunctionTestCase (testSomething) returned returned <unittest.result.TestResult run=1 errors=1 failures=0>, not a test

Apparently calling a TestCase instance invokes TestCase.run()!

The only way I can think of making such a test discoverable is my making a subclass. But as demonstrated by my example module, this is more cumbersome than bypassing FunctionTestCase altogether.

----------
components: Library (Lib)
files: test_module.py
messages: 233276
nosy: vadmium
priority: normal
severity: normal
status: open
title: Integration of unittest.FunctionTestCase with automatic discovery and loading
type: enhancement
versions: Python 3.5
Added file: http://bugs.python.org/file37579/test_module.py

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


More information about the Python-bugs-list mailing list