This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: Integration of unittest.FunctionTestCase with automatic discovery and loading
Type: enhancement Stage:
Components: Library (Lib) Versions: Python 3.5
process
Status: open Resolution:
Dependencies: Superseder:
Assigned To: Nosy List: ezio.melotti, martin.panter, michael.foord, r.david.murray, rbcollins
Priority: normal Keywords:

Created on 2015-01-01 07:58 by martin.panter, last changed 2022-04-11 14:58 by admin.

Files
File name Uploaded Description Edit
test_module.py martin.panter, 2015-01-01 07:58 Example test module
Messages (2)
msg233276 - (view) Author: Martin Panter (martin.panter) * (Python committer) Date: 2015-01-01 07:58
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.
msg233287 - (view) Author: R. David Murray (r.david.murray) * (Python committer) Date: 2015-01-01 16:06
According to the docs, there's no reason to use FunctionTestCase unless you are dealing with legacy test code (eg: importing it from some existing module), so yes your "this seems easier" is certainly easier :)

(I wasn't even aware FunctionTestCase existed.)

I'm not sure what the issues would be with making them discoverable.  We'll wee what Robert and/or Michael have to say.
History
Date User Action Args
2022-04-11 14:58:11adminsetgithub: 67331
2015-01-01 16:06:36r.david.murraysetnosy: + r.david.murray
messages: + msg233287
2015-01-01 10:00:51ned.deilysetnosy: + rbcollins, ezio.melotti, michael.foord
2015-01-01 07:58:44martin.pantercreate