Decorated function names are not preserved

Reported by kumar303 on 2011-04-06
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
CaptureMock
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.

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
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  Edit
Everyone can see this information.

Other bug subscribers