assertRaises gives error about a lambda

Bug #881052 reported by Jonathan Lange
16
This bug affects 2 people
Affects Status Importance Assigned to Milestone
testtools
Fix Released
Critical
Jonathan Lange

Bug Description

======================================================================
FAIL: tests.test_database.TestDatabase.test_double_insert
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/jml/src/pkgme-binary/symbol-database/devportalbinary/tests/test_database.py", line 38, in test_double_insert
    db.insert_new_library, 'libfoo.so.0', 'foo')
  File "/usr/lib/python2.7/dist-packages/testtools/testcase.py", line 388, in assertRaises
    self.assertThat(lambda: callableObj(*args, **kwargs), matcher)
  File "/usr/lib/python2.7/dist-packages/testtools/testcase.py", line 411, in assertThat
    raise MismatchError(matchee, matcher, mismatch, verbose)
MismatchError: <function <lambda> at 0x365ff50> returned None
id=65, tests=46, failures=1

The MismatchError would be more helpful if it said "db.insert_new_library" or "insert_new_library", rather than a lambda that testtools made up.

Tags: regression

Related branches

Revision history for this message
Robert Collins (lifeless) wrote :

I think we could sanely poke inside the lambda to get at the function it calls; that may sound invasive but will:
 - make our rendering nicer
 - handle lambda supplied *to us* more nicely as well.

Changed in testtools:
status: New → Triaged
importance: Undecided → Critical
tags: added: regression
Revision history for this message
Jonathan Lange (jml) wrote :

I've taken a different approach in my proposed patch.

Changed in testtools:
status: Triaged → In Progress
assignee: nobody → Jonathan Lange (jml)
Jonathan Lange (jml)
Changed in testtools:
status: In Progress → Fix Committed
milestone: none → next
Jonathan Lange (jml)
Changed in testtools:
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Duplicates of this bug

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.