次の非常に単純な単体テストは 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