[docs] unittest.TestLoader().discover() returns suites and not modules as documented

Himanshu himanshu.garg at gmail.com
Sun Oct 21 09:57:53 CEST 2012


The following lines from the docs :-

--BEGIN
discover(start_dir, pattern='test*.py', top_level_dir=None)
Find and return all test modules
--END

are perhaps inaccurate as the discover module returns suites :-

--BEGIN
Python 2.7.3 (default, Apr 10 2012, 23:31:26) [MSC v.1500 32 bit
(Intel)] on win32

>>> import unittest
>>> print unittest.TestLoader().discover('.', pattern='Compliance*.py')
<unittest.suite.TestSuite tests=[<unittest.suite.TestSuite
tests=[<unittest.suite.TestSuite
tests=[<ComplianceConflicts.ComplianceConflicts
testMethod=test_a>]>]>, <unittest.suite.TestSuite
tests=[<unittest.suite.TestSuite
tests=[<ComplianceNames.ComplianceNames testMethod=test_b>]>]>]>
--END

>From my understanding of the docs I used
unittest.TestLoader().loadTestsFromModule() on the results of
discover(). That of course didn't work.

Thanks,
Himanshu


More information about the docs mailing list