Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Python > ValueError: need more than 2 values to unpack

Reply
Thread Tools

ValueError: need more than 2 values to unpack

 
 
kahmed
Guest
Posts: n/a
 
      04-01-2011
When running nosetests i get error:

test_many_errors.test_value_two ... SKIP: (<type
'exceptions.ValueError'>, ValueError(), <traceback object at
0x1218cd8>)
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 "/Library/Frameworks/Python.framework/Versions/6.3/lib/
python2.6/site-packages/nosetrim-0.1.dev_r13-py2.6.egg/nosetrim/
nosetrim.py", line 136, in printErrors
lambda i: get_error_count(self._error_lookup, i))
File "/Library/Frameworks/Python.framework/Versions/6.3/lib/
python2.6/site-packages/nosetrim-0.1.dev_r13-py2.6.egg/nosetrim/
nosetrim.py", line 142, in printErrorList
for test, err, capt in errors:
ValueError: need more than 2 values to unpack
/

--------------------- >> end captured stdout << ----------------------

line 142 is:

"for test, err, capt in errors:"

Here is the code snippet:

def get_error_count(lookup, index):
if index in lookup:
ename = lookup[index]
return _errormap[ename]

self.printErrorList('ERROR', self.errors,
lambda i: get_error_count(self._error_lookup, i))
self.printErrorList('FAIL', self.failures,
lambda i: get_error_count(self._failure_lookup,
i))

def printErrorList(self, flavor, errors, get_error_count):
i = 0
for test, err, capt in errors:
self.stream.writeln(self.separator1)
self.stream.writeln("%s: %s" %
(flavor,self.getDescription(test)))
self.stream.writeln(self.separator2)
self.stream.writeln("%s" % err)
#count = get_error_count(i)
count = get_error_count(i)
if count > 1:
self.stream.writeln(self.separator2)
self.stream.writeln("+ %s more" % (count-1))
self.stream.writeln(self.separator2)
if capt is not None and len(capt):
self.stream.writeln(ln('>> begin captured stdout <<'))
self.stream.writeln(capt)
self.stream.writeln(ln('>> end captured stdout <<'))
i += 1


How do i resolve this ?

Thanks,
-Kamal.
 
Reply With Quote
 
 
 
 
John Nagle
Guest
Posts: n/a
 
      04-01-2011
On 4/1/2011 7:48 AM, kahmed wrote:

>
> line 142 is:
>
> "for test, err, capt in errors:"


Somewhere in "errors" is a value that is not of length 3.

Try this to find out what's wrong:

for errorentry in errors :
try :
(test, err, capt) = errorentry # try to unpack
except ValueError as message : # unpack failed
raise(ValueError("%s: bogus entry in 'errors': %s" %
(message, repr(errorentry))))
...


John Nagle

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Re: Unpack less values from function's return values Chris Rebert Python 1 05-28-2009 02:47 PM
Like all great travelers, I have seen more than I remember andremember more than I have seen. shenrilaa@gmail.com C++ 0 03-05-2008 08:41 AM
Like all great travelers, I have seen more than I remember andremember more than I have seen. shenrilaa@gmail.com C Programming 0 03-05-2008 03:26 AM
ValueError: need more than 1 value to unpack laxmikiran.bachu@gmail.com Python 0 05-24-2007 04:34 AM
ValueError: need more than 3 values to unpack Elezar Simeon Papo Python 3 02-07-2006 05:39 PM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57