Issue6866
Created on 2009-09-08 20:03 by MarkRoddy, last changed 2022-04-11 14:56 by admin. This issue is now closed.
| Files | ||||
|---|---|---|---|---|
| File name | Uploaded | Description | Edit | |
| unittest.patch | MarkRoddy, 2009-09-08 20:03 | patch for unittest.py to correct observed behavior and two tests fixtures that check for desired behavior | ||
| unittest.trunk.patch | MarkRoddy, 2009-09-08 21:27 | |||
| Messages (4) | |||
|---|---|---|---|
| msg92427 - (view) | Author: Mark Roddy (MarkRoddy) * | Date: 2009-09-08 20:03 | |
The TestLoader class in unittest.py has an attribute 'suiteClass' that is used to create instances of TestSuite object(s) in the process of loading tests. If it is desired to subclass the TestSuite class then consumers may set this attribute on a TestLoader object in order to override what TestSuite class gets instantiated (a pythonic version of the factory method pattern). However, the loadTestsFromName() on the TestLoader class does not use this attribute to create TestSuite instances, and instead has a hard coded reference to the unittest.TestSuite class. This results in the base class being created instead of a possibly desired subclass that has been specified via this attribute. Solution for this issue is to change the loadTestsFromName() method to use the suiteClass attribute when creating TestSuite objects instead using a reference to the TestSuite class. Included is a patch that implements this behavior as well as two additional test for the test_unittest.py file which expose this issue if run against an unpatched version of unittest. |
|||
| msg92430 - (view) | Author: R. David Murray (r.david.murray) * ![]() |
Date: 2009-09-08 20:24 | |
I haven't run the tests, but a quick glance at the code makes me think this is still probably an issue in 2.7/3.1. |
|||
| msg92433 - (view) | Author: Mark Roddy (MarkRoddy) * | Date: 2009-09-08 21:27 | |
The issue appears to be in the other versions mentioned from manual inspection. Also adding another patch as unittest in the trunk has been broken apart into a package with several modules so the original patch will not work there. |
|||
| msg92575 - (view) | Author: Michael Foord (michael.foord) * ![]() |
Date: 2009-09-13 17:28 | |
Committed revision 74783. |
|||
| History | |||
|---|---|---|---|
| Date | User | Action | Args |
| 2022-04-11 14:56:52 | admin | set | github: 51115 |
| 2009-09-13 17:28:51 | michael.foord | set | status: open -> closed resolution: accepted messages: + msg92575 |
| 2009-09-08 21:27:49 | MarkRoddy | set | files:
+ unittest.trunk.patch messages: + msg92433 |
| 2009-09-08 20:25:00 | r.david.murray | set | priority: normal assignee: michael.foord messages:
+ msg92430 |
| 2009-09-08 20:03:48 | MarkRoddy | create | |
