Merge lp:~jml/testtools/assert-raises-lambda into lp:~testtools-committers/testtools/trunk
Proposed by
Jonathan Lange
Status: | Merged | ||||
---|---|---|---|---|---|
Merged at revision: | 240 | ||||
Proposed branch: | lp:~jml/testtools/assert-raises-lambda | ||||
Merge into: | lp:~testtools-committers/testtools/trunk | ||||
Diff against target: |
171 lines (+93/-2) 4 files modified
NEWS (+6/-0) doc/for-test-authors.rst (+21/-0) testtools/testcase.py (+21/-2) testtools/tests/test_testcase.py (+45/-0) |
||||
To merge this branch: | bzr merge lp:~jml/testtools/assert-raises-lambda | ||||
Related bugs: |
|
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Robert Collins | Approve | ||
Review via email:
|
Description of the change
When assertRaises currently fails, it doesn't mention the callable that it was invoked with. Instead it mentions a lambda that we make up in order to be able to re-use the Raises matcher.
This patch addresses this problem by using a wrapper object instead of a lambda. The wrapper object is a nullary callable and has a custom __repr__ method that forwards to the callable that assertRaises was invoked with.
To post a comment you must log in.
Note that this is the sort of thing that's likely to trip up with cross-Python compatibility – I've only tested on Python 2.7.
We need to make sure that trunk passes on all supported Pythons before releasing.