This issue tracker has been migrated to GitHub ,
and is currently read-only.
For more information,
see the GitHub FAQs in the Python's Developer Guide.
Created on 2012年05月31日 19:02 by alex.75, last changed 2022年04月11日 14:57 by admin. This issue is now closed.
| Files | ||||
|---|---|---|---|---|
| File name | Uploaded | Description | Edit | |
| unittest_method_name_difference.patch | r.david.murray, 2012年06月02日 21:06 | review | ||
| unittest_method_name_difference_27.patch | Claudiu.Popa, 2013年08月20日 20:17 | review | ||
| Messages (10) | |||
|---|---|---|---|
| msg162015 - (view) | Author: Alessandro Piccione (alex.75) | Date: 2012年05月31日 19:02 | |
Steps to reproduce the problem.
1. Create a module (ex. name it "test")
2. Create a file in it (ex. mainTest.py) with a class (ex. MainTest) derived from TestCase.
3. Create a test method in that class, (ex. test_base), prefix it with "test".
4. Create a decorator (ex. clear_args) and use it on the test method
5. Create a test suite with the function "loadTestsFromName" of TestLoader class and make a TestRunner run it (I use a TextTestRunner).
suite = unittest.TestLoader().loadTestsFromName('test.mainTest.MainTest.test_base')
unittest.TextTestRunner(verbosity=2).run(suite)
It is expected that the test is run (it runs without decorator).
It gives an error: no such test method in <class 'test.mainTest.MainTest'>: wrapper.
"wrapper" is the name of the returned function in the decorator.
I'm using Python 2.7.3 on Windows 7 64bit.
I search "loadTestsFromName decorator" without results, so I decided to report as new issue. This is my first report, I admit I've not read any guide/instructions.
|
|||
| msg162017 - (view) | Author: R. David Murray (r.david.murray) * (Python committer) | Date: 2012年05月31日 19:58 | |
I don't think this is documented anywhere (and should be). I believe what you need to do is use functools.wraps on your wrapper function. |
|||
| msg162032 - (view) | Author: Michael Foord (michael.foord) * (Python committer) | Date: 2012年05月31日 23:36 | |
Whilst functools.wraps would fix the problem it still sounds like a bug (or at the very least a reasonable feature request). |
|||
| msg162176 - (view) | Author: R. David Murray (r.david.murray) * (Python committer) | Date: 2012年06月02日 21:06 | |
Here's a patch. |
|||
| msg162563 - (view) | Author: Michael Foord (michael.foord) * (Python committer) | Date: 2012年06月09日 14:56 | |
Patch looks great - thanks David. |
|||
| msg186558 - (view) | Author: Roundup Robot (python-dev) (Python triager) | Date: 2013年04月11日 12:58 | |
New changeset b17bcfadd7f3 by R David Murray in branch '3.3': #14971: Use class method name, not function.__name__, during unittest discovery. http://hg.python.org/cpython/rev/b17bcfadd7f3 New changeset 659c89275be2 by R David Murray in branch 'default': Merge #14971: Use class method name, not function.__name__, during unittest discovery. http://hg.python.org/cpython/rev/659c89275be2 |
|||
| msg186559 - (view) | Author: R. David Murray (r.david.murray) * (Python committer) | Date: 2013年04月11日 13:00 | |
Fixed in Python3. The 2.7 unittest code is different enough that it is not immediately obvious how to make the equivalent fix (given that it has been a while since I looked at this logic). If someone wants to work out the equivalent 2.7 patch, I will apply it. |
|||
| msg195714 - (view) | Author: PCManticore (Claudiu.Popa) * (Python triager) | Date: 2013年08月20日 20:17 | |
The patch for Python 2.7 is pretty similar with the one provided for Python 3. |
|||
| msg195758 - (view) | Author: Michael Foord (michael.foord) * (Python committer) | Date: 2013年08月21日 09:31 | |
Cool, thanks! |
|||
| msg197219 - (view) | Author: Roundup Robot (python-dev) (Python triager) | Date: 2013年09月08日 03:34 | |
New changeset 78a5de507f19 by Michael Foord in branch '2.7': Closes issue 14971. http://hg.python.org/cpython/rev/78a5de507f19 |
|||
| History | |||
|---|---|---|---|
| Date | User | Action | Args |
| 2022年04月11日 14:57:31 | admin | set | github: 59176 |
| 2013年09月08日 03:34:23 | python-dev | set | status: open -> closed resolution: fixed messages: + msg197219 stage: needs patch -> resolved |
| 2013年08月21日 09:31:54 | michael.foord | set | assignee: michael.foord messages: + msg195758 |
| 2013年08月20日 20:17:01 | Claudiu.Popa | set | files:
+ unittest_method_name_difference_27.patch nosy: + Claudiu.Popa messages: + msg195714 |
| 2013年04月11日 13:00:48 | r.david.murray | set | assignee: michael.foord -> (no value) stage: needs patch messages: + msg186559 versions: - Python 3.2, Python 3.3 |
| 2013年04月11日 12:58:38 | python-dev | set | nosy:
+ python-dev messages: + msg186558 |
| 2013年04月11日 12:53:35 | r.david.murray | set | nosy:
+ eckhardt |
| 2013年04月11日 12:53:14 | r.david.murray | link | issue17696 superseder |
| 2012年06月09日 14:56:48 | michael.foord | set | assignee: docs@python -> michael.foord messages: + msg162563 |
| 2012年06月02日 21:06:01 | r.david.murray | set | files:
+ unittest_method_name_difference.patch keywords: + patch messages: + msg162176 components: + Library (Lib), - Documentation |
| 2012年05月31日 23:36:07 | michael.foord | set | messages: + msg162032 |
| 2012年05月31日 19:58:28 | r.david.murray | set | versions:
+ Python 3.2, Python 3.3 nosy: + docs@python, r.david.murray, michael.foord messages: + msg162017 assignee: docs@python components: + Documentation, - None |
| 2012年05月31日 19:02:18 | alex.75 | create | |