classification
Title: lookup fails for renamed functions
Type: behavior Stage: resolved
Components: Tests Versions: Python 3.2, Python 3.3, Python 2.7
process
Status: closed Resolution: duplicate
Dependencies: Superseder: (unittest) loadTestsFromName does not work on method with a decorator
View: 14971
Assigned To: Nosy List: eckhardt, r.david.murray
Priority: normal Keywords:

Created on 2013-04-11 07:08 by eckhardt, last changed 2013-04-11 12:53 by r.david.murray. This issue is now closed.

Files
File name Uploaded Description Edit
name_mod.py eckhardt, 2013-04-11 07:08 example
Messages (2)
msg186549 - (view) Author: Ulrich Eckhardt (eckhardt) Date: 2013-04-11 07:08
When you rename a test function, you can't explicitly specify it on the commandline any more. During normal test runs, it is automatically discovered though. The error is that the old name was not found, even though the new name was specified. The attached example changes the name attached to the function (its __name__ attribute) for demonstration. The same problem occurs if you auto-generate test functions and attach them to the class, using post-processing or a metaclass. The cases all have in common that the name in the class' dict is not the same as the function's __name__, so cls.foo.__name__ is not "foo".

See http://mail.python.org/pipermail/python-list/2013-April/644863.html for the initial discussion on the mailinglist. While I only tested Python 2.7 there, it also fails for 3.2 and 3.3.
msg186557 - (view) Author: R. David Murray (r.david.murray) * (Python committer) Date: 2013-04-11 12:53
Well, actually, the old name *is* found, it is the new name that is not found in the class dict when unittest goes to actually run the test.

This is a duplicate of issue 14971.  I thought I had applied that patch, but obviously I haven't, and neither did Michael.  I will fix that.
History
Date User Action Args
2013-04-11 12:53:14r.david.murraysetstatus: open -> closed

superseder: (unittest) loadTestsFromName does not work on method with a decorator

nosy: + r.david.murray
messages: + msg186557
resolution: duplicate
stage: resolved
2013-04-11 07:08:20eckhardtcreate