Message98469
| Author |
r.david.murray |
| Recipients |
r.david.murray |
| Date |
2010年01月28日.18:17:23 |
| SpamBayes Score |
8.149566e-08 |
| Marked as misclassified |
No |
| Message-id |
<1264702646.96.0.224010366293.issue7799@psf.upfronthosting.co.za> |
| In-reply-to |
| Content |
Working from the example in the docs, I wrote a test suite like this:
def load_tests(loader, standard_tests, pattern):
for case in email.test.emailtestdb.populated_test_cases(globals()):
standard_tests.addTests(loader.loadFromTestCase(case))
return standard_test
This resulted in the exception:
Traceback (most recent call last):
File "/home/rdmurray/python/bzr/email6-local/Lib/test/regrtest.py", line 857, in runtest_inner
indirect_test()
File "/home/rdmurray/python/bzr/email6-local/Lib/test/test_email.py", line 10, in test_main
tests = unittest.defaultTestLoader.discover(testdir, top_level_dir=libdir)
File "/home/rdmurray/python/bzr/email6-local/Lib/unittest/loader.py", line 179, in discover
return self.suiteClass(tests)
File "/home/rdmurray/python/bzr/email6-local/Lib/unittest/suite.py", line 18, in __init__
self.addTests(tests)
File "/home/rdmurray/python/bzr/email6-local/Lib/unittest/suite.py", line 54, in addTests
self.addTest(test)
File "/home/rdmurray/python/bzr/email6-local/Lib/unittest/suite.py", line 43, in addTest
raise TypeError("{} is not callable".format(test))
TypeError: [<unittest.suite.TestSuite tests=[]>, <unittest.suite.TestSuite tests=[]>, <unittest.suite.TestSuite tests=[]>] is not callable
(Well, that's after I enhanced the normal error message, which just says that 'test must be a callable')
I see that loadTestsFromModule wraps what is passes as standard_tests in self.suiteClass before returning it, whereas it returns whatever load_tests returns directly. Perhaps the wrapping needs to be done in both cases, or perhaps standard_tests should be wrapped before being passed to the module's load_tests?
My load_tests is a function in a test module, not a package __init__. |
|
History
|
|---|
| Date |
User |
Action |
Args |
| 2010年01月28日 18:17:27 | r.david.murray | set | recipients:
+ r.david.murray |
| 2010年01月28日 18:17:26 | r.david.murray | set | messageid: <1264702646.96.0.224010366293.issue7799@psf.upfronthosting.co.za> |
| 2010年01月28日 18:17:25 | r.david.murray | link | issue7799 messages |
| 2010年01月28日 18:17:24 | r.david.murray | create |
|