1
我只是試圖執行下面一個簡單的測試用例列表,缺少必需的位置參數 - nosetests
# testinheritence.py
import unittest
class heleClass(object):
def execute_test_plan(self, test_plan):
self.assertEqual("a", "a")
class TestParent(heleClass):
def testName(self):
test_plan = {"a": 1}
self.execute_test_plan(test_plan)
class SqlInheritance(unittest.TestCase, TestParent):
print ("get into inheritance")
if __name__ == "__main__":
unittest.main()
然後用這個命令來測試它:「nosetests3 -s testinheritence.py」但我堅持遇到這些異常,它抱怨,
======================================================================
ERROR: testinheritence.TestParent.execute_test_plan
----------------------------------------------------------------------
Traceback (most recent call last):
File "/usr/lib/python3/dist-packages/nose/case.py", line 198, in runTest
self.test(*self.arg)
TypeError: execute_test_plan() missing 1 required positional argument: 'test_plan'
======================================================================
ERROR: testinheritence.TestParent.testName
----------------------------------------------------------------------
Traceback (most recent call last):
File "/usr/lib/python3/dist-packages/nose/case.py", line 198, in runTest
self.test(*self.arg)
File "/home/dave/scripts/testinheritence.py", line 16, in testName
self.execute_test_plan(test_plan)
File "/home/dave/scripts/testinheritence.py", line 10, in execute_test_plan
self.assertEqual("a", "a")
AttributeError: 'TestParent' object has no attribute 'assertEqual'
----------------------------------------------------------------------
Ran 4 tests in 0.003s
與「蟒蛇-m單元測試testinheritence」來運行它,測試用例會順利通過,我GOOGLE了這一點,但還沒收到approache修復它,有什麼我錯過了嗎?任何迴應都非常受歡迎!
感謝解決我的問題完全,謝謝! – jungler