初めて PyDev 内で PyUnit を使用しようとしています。unittest.pyモジュールを作成しました。を実行するとrun as -> Python unit-test、次のエラーが発生しました。
ファイルを検索中...完了。
テスト モジュールのインポート中 ... 完了。
================================================== ====================
トレースバック (最新の呼び出しが最後):
ファイル "/Applications/eclipse/plugins/org.python.pydev_2.7.5.2013052819/pysrc/runfiles.py"、163 行目
主要()
メインのファイル「/Applications/eclipse/plugins/org.python.pydev_2.7.5.2013052819/pysrc/runfiles.py」、77行目
pydev_runfiles.main(構成)
メインのファイル「/Applications/eclipse/plugins/org.python.pydev_2.7.5.2013052819/pysrc/pydev_runfiles.py」の761行目
PydevTestRunner(構成).run_tests()
ファイル「/Applications/eclipse/plugins/org.python.pydev_2.7.5.2013052819/pysrc/pydev_runfiles.py」、747行目、run_tests
runner.run(テストスイート)
ファイル "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/unittest/runner.py"、158 行目、実行中
結果.printErrors()
ファイル「/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/unittest/runner.py」、108行目、printErrors
self.printErrorList('エラー', self.errors)
ファイル「/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/unittest/runner.py」、114行目、printErrorList
self.stream.writeln("%s: %s" % (flavor,self.getDescription(test)))
ファイル "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/unittest/runner.py"、46 行目、getDescription 内
return '\n'.join((str(test), doc_first_line))
ファイル "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/unittest/case.py"、1060 行目、__str__ 内
self._testFunc.__name__)
AttributeError: 'str' オブジェクトに属性 '__name__' がありません
私の単体テストは、PyDev によって生成されたデフォルトです。
import unittest
class Test(unittest.TestCase):
def setUp(self):
pass
def tearDown(self):
pass
def testName(self):
pass
print "hello test"
if __name__ == "__main__":
#import sys;sys.argv = ['', 'Test.testName']
unittest.main()
印刷されると思っていましたhello test。私は何が欠けていますか?