ValueError: need more than 2 values to unpack

Discussion in 'Python' started by kahmed, Apr 1, 2011.

  1. kahmed

    kahmed Guest

    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.
     
    kahmed, Apr 1, 2011
    #1
    1. Advertising

  2. kahmed

    John Nagle Guest

    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
     
    John Nagle, Apr 1, 2011
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Elezar Simeon Papo

    ValueError: need more than 3 values to unpack

    Elezar Simeon Papo, Jan 21, 2006, in forum: Python
    Replies:
    3
    Views:
    1,446
    Elezar Simeon Papo
    Feb 7, 2006
  2. Replies:
    2
    Views:
    27,452
  3. fscked
    Replies:
    8
    Views:
    375
    Bruno Desthuilliers
    Apr 11, 2007
  4. Replies:
    0
    Views:
    1,497
  5. Shawn Minisall

    ValueError: too many values to unpack,>>>

    Shawn Minisall, Sep 27, 2007, in forum: Python
    Replies:
    9
    Views:
    836
    Bruno Desthuilliers
    Sep 28, 2007
Loading...

Share This Page