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: unittest.TestLoader.discover return value incorrectly documented.
Type: enhancement Stage: resolved
Components: Documentation Versions: Python 3.3, Python 3.4
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: docs@python Nosy List: Lita.Cho, arnaut-billings, docs@python, ezio.melotti, michael.foord, python-dev, r.david.murray, zormit
Priority: normal Keywords: easy, patch

Created on 2013-12-20 09:02 by arnaut-billings, last changed 2022-04-11 14:57 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
unittest_doc.patch Lita.Cho, 2014-03-10 22:46 review
unittest_doc.patch Lita.Cho, 2014-03-11 02:04 review
Messages (8)
msg206670 - (view) Author: Arnaut Billings (arnaut-billings) Date: 2013-12-20 09:02
Here: http://docs.python.org/3/library/unittest.html#unittest.TestLoader.discover

it states that "Find and return all test modules ..."

This implies that in order to get a test suite, one has to iterate over the return value of unittest.TestLoader.discover and call loadTestsFromModule for each module.

But, the type of the result of unittest.TestLoader.discover returns: <class 'unittest.suite.TestSuite'>
msg213080 - (view) Author: Lita Cho (Lita.Cho) * Date: 2014-03-10 20:35
Hello! I would like to tackle this. Does that mean the documentation needs to change such that it states that the TestSuite object is returned? It looks you can iterate over the unittest.suite.TestSuite object, as I am getting something like this:

<unittest.suite.TestSuite tests=[<unittest.suite.TestSuite tests=[<unittest.loader.ModuleImportFailure testMethod=badsyntax_3131>]>, <unittest.suite.TestSuite tests=[<unittest.loader.ModuleImportFailure testMethod=badsyntax_future10>]>, <unittest.suite.TestSuite tests=[<unittest.loader.ModuleImportFailure testMethod=badsyntax_future3>]>, <unittest.suite.TestSuite tests=[<unittest.loader.ModuleImportFailure testMethod=badsyntax_future4>]>, <unittest.suite.TestSuite tests=[<unittest.loader.ModuleImportFailure testMethod=badsyntax_future5>]>, <unittest.suite.TestSuite tests=[<unittest.loader.ModuleImportFailure testMethod=badsyntax_future6>]>, <unittest.suite.TestSuite tests=[<unittest.loader.ModuleImportFailure testMethod=badsyntax_future7>]>, <unittest.suite.TestSuite tests=[<unittest.loader.ModuleImportFailure testMethod=badsyntax_future8>]>, <unittest.suite.TestSuite tests=[<unittest.loader.ModuleImportFailure testMethod=badsyntax_future9>]>, <unittest.suite.TestSuite tests=[<unittest.loader.ModuleImportFailure testMethod=badsyntax_pep3120>]>]>
msg213083 - (view) Author: R. David Murray (r.david.murray) * (Python committer) Date: 2014-03-10 20:57
It should say that it finds all the test modules and returns a TestSuite containing them.
msg213106 - (view) Author: Lita Cho (Lita.Cho) * Date: 2014-03-10 22:46
Hello!

I have created a patch for the new documentation. I would love it if I could get feedback. Thanks!
msg213108 - (view) Author: R. David Murray (r.david.murray) * (Python committer) Date: 2014-03-11 00:03
'returns' should be 'return', but otherwise it looks good to me.
msg213112 - (view) Author: Lita Cho (Lita.Cho) * Date: 2014-03-11 02:04
Good catch! I fixed that and loaded it in the attached patch!
msg213181 - (view) Author: Roundup Robot (python-dev) (Python triager) Date: 2014-03-11 22:47
New changeset cc74393062f7 by R David Murray in branch '2.7':
#20030: doc that TestLoader.discover returns a TestSuite.
http://hg.python.org/cpython/rev/cc74393062f7

New changeset 71df53af61ec by R David Murray in branch '3.3':
#20030: doc that TestLoader.discover returns a TestSuite.
http://hg.python.org/cpython/rev/71df53af61ec

New changeset ecc26a050384 by R David Murray in branch 'default':
Merge #20030: doc that TestLoader.discover returns a TestSuite.
http://hg.python.org/cpython/rev/ecc26a050384
msg213182 - (view) Author: R. David Murray (r.david.murray) * (Python committer) Date: 2014-03-11 22:49
Thanks, Lita.
History
Date User Action Args
2022-04-11 14:57:55adminsetgithub: 64229
2014-03-11 22:49:02r.david.murraysetstatus: open -> closed
resolution: fixed
messages: + msg213182

stage: needs patch -> resolved
2014-03-11 22:47:11python-devsetnosy: + python-dev
messages: + msg213181
2014-03-11 02:04:10Lita.Chosetfiles: + unittest_doc.patch

messages: + msg213112
2014-03-11 00:03:52r.david.murraysetmessages: + msg213108
2014-03-10 22:46:11Lita.Chosetfiles: + unittest_doc.patch
keywords: + patch
messages: + msg213106
2014-03-10 20:57:40r.david.murraysetnosy: + r.david.murray
messages: + msg213083
2014-03-10 20:35:22Lita.Chosetnosy: + Lita.Cho
messages: + msg213080
2014-01-27 22:04:22zormitsetnosy: + zormit
2013-12-20 09:24:21ezio.melottisetversions: + Python 3.4
nosy: + ezio.melotti, michael.foord

keywords: + easy
type: enhancement
stage: needs patch
2013-12-20 09:02:25arnaut-billingscreate