我得到錯誤:ValueError:需要超過2個值來解壓 當我現在運行單元測試,所以2個故障和一個跳過 現在遠正如我已經讀到ValueError:需要超過2個值來解壓Python 2.6.6
lambda i: get_error_count(self._error_lookup, i))
線源142是具有的代碼行的方法
for test, err, capt in errors:
:
count = get_error_count(i)
參考 Python 3.0有點像這樣。過量的值可以被綁定 (作爲一個列表),以最後一個變量:
A,B,* C = [1,2,3,4,5]
將導致含有C [3, 4,5]。
在Python 2.x中,你不能這樣做直接的,但你應該能夠 創建延長或縮短的參數 輸入元組到正確的長度,所以你可以做一個函數:
a,c,b = fix(1,2) d,e,f = fix(1,2,3,4)
但是,該功能將不知道左側 序列的長度,所以它將不得不作爲額外參數傳入或硬編碼。
所以
count = get_error_count(i) uses only one variable, where as def get_error_count(lookup, index): takes on 2
我應該作爲第二個變量有什麼用?解決這個問題?
謝謝, -Kamal。
-------------------- >> begin capture stdout < < ------------------- -
\ test_many_errors.test_assert_one ... FAIL test_many_errors.test_one ... OK test_many_errors.test_assert_two ...錯誤 test_many_errors.test_two ... OK test_many_errors.test_value_one ...錯誤 test_many_errors。 test_value_two ...跳過:(,ValueError(),) test_many_errors.test_good_one ... ok test_many_errors.test_good_two ... ok
Traceback (most recent call last):
File "/Library/Frameworks/Python.framework/Versions/Current/bin/nosetests", line 10, in <module>
sys.exit(run_exit())
File "/Library/Frameworks/Python.framework/Versions/6.3/lib/python2.6/site-packages/nose/core.py", line 117, in __init__
**extra_args)
File "/Library/Frameworks/Python.framework/Versions/6.3/lib/python2.6/unittest.py", line 817, in __init__
self.runTests()
File "/Library/Frameworks/Python.framework/Versions/6.3/lib/python2.6/site-packages/nose/core.py", line 196, in runTests
result = self.testRunner.run(self.test)
File "/Library/Frameworks/Python.framework/Versions/6.3/lib/python2.6/site-packages/nose/core.py", line 63, in run
result.printErrors()
File "/NOSE_TRIM/nosetrim-read-only/nosetrim/nosetrim.py", line 136, in printErrors
lambda i: get_error_count(self._error_lookup, i))
File "/NOSE_TRIM/nosetrim-read-only/nosetrim/nosetrim.py", line 142, in printErrorList
for test, err, capt in errors:
ValueError: need more than 2 values to unpack
/
--------------------- >>結束時捕獲的stdout < < ----------- -----------
ran 3 test in 1。263S