Decorated function names are not preserved

Bug #753003 reported by kumar303
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
CaptureMock
Fix Released
Undecided
Unassigned

Bug Description

The @capturemock decorator returns a wrapped function without preserving the original name of the function. This interferes with test runners that run functions by discovery (e.g. Nose, py.test, unittest2).

The fix for this is to simply copy original_function.__name__ into the new function and as of 2.5 there is a builtin functools function for this called wraps. Attached is a basic patch with wraps showing how it works.

Revision history for this message
kumar303 (kumar-mcmillan) wrote :
Revision history for this message
Geoff Bache (geoff.bache) wrote :

CaptureMock has its own bugtracker...

Many thanks for the patch, will try to integrate it in the next couple of days.

affects: texttest → capturemock
Revision history for this message
Geoff Bache (geoff.bache) wrote :

Integrated and added test.

Actually py.test, which I've mostly been using when not using TextTest, coped with this situation fine (wonder how) but at least nose didn't.

Changed in capturemock:
status: New → Fix Committed
Changed in capturemock:
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

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