以下超级简单的单元测试在python2.7下运行良好,但在2.6中出现以下错误“no method runTest()”,这是为什么呢?
谢谢!杨
myuser@myhost /tmp $ python26 -m unittest a.AA
Traceback (most recent call last):
File "/usr/lib64/python2.6/runpy.py", line 122, in _run_module_as_main
"__main__", fname, loader, pkg_name)
File "/usr/lib64/python2.6/runpy.py", line 34, in _run_code
exec code in run_globals
File "/usr/lib64/python2.6/unittest.py", line 874, in <module>
main(module=None)
File "/usr/lib64/python2.6/unittest.py", line 815, in __init__
self.parseArgs(argv)
File "/usr/lib64/python2.6/unittest.py", line 842, in parseArgs
self.createTests()
File "/usr/lib64/python2.6/unittest.py", line 848, in createTests
self.module)
File "/usr/lib64/python2.6/unittest.py", line 612, in loadTestsFromNames
suites = [self.loadTestsFromName(name, module) for name in names]
File "/usr/lib64/python2.6/unittest.py", line 597, in loadTestsFromName
test = obj()
File "/usr/lib64/python2.6/unittest.py", line 215, in __init__
(self.__class__, methodName)
ValueError: no such test method in <class 'a.AA'>: runTest
myuser@myhost /tmp $ vi a.py
myuser@myhost /tmp $ cat a.py
import unittest
class AA(unittest.TestCase):
pass