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.

classification
Title: unittest discover should provide a way to define discovery at package level
Type: Stage: resolved
Components: Versions:
process
Status: closed Resolution: rejected
Dependencies: Superseder:
Assigned To: michael.foord Nosy List: barry, michael.foord, r.david.murray, rbcollins, vila
Priority: normal Keywords:

Created on 2013-06-12 08:01 by vila, last changed 2022-04-11 14:57 by admin. This issue is now closed.

Messages (6)
msg191015 - (view) Author: (vila) Date: 2013-06-12 08:01
While most test suites are a tree with test_*.py files, there are cases where being able to define the discovery for a subtree in the package __init__.py file comes handy.

A poc implementation is available at 
http://bazaar.launchpad.net/~canonical-isd-qa/selenium-simple-test/trunk/view/head:/src/sst/tests/test_loader.py 

http://bazaar.launchpad.net/~canonical-isd-qa/selenium-simple-test/trunk/view/head:/src/sst/loader.py

It allows test writers to define their own discovery when needed (including a specific edge case for the project mentioned above: test scripts that should not be imported at load time).

It also addresses http://bugs.python.org/issue16662
msg191016 - (view) Author: Robert Collins (rbcollins) * (Python committer) Date: 2013-06-12 08:04
This is a duplicate of 16662
msg191017 - (view) Author: Robert Collins (rbcollins) * (Python committer) Date: 2013-06-12 08:07
Well, spoke with vila on IRC. I content it's a duplicate because if load_tests in __init__ kicks in and supercedes discovery, I believe this bug would not be needed.
msg191023 - (view) Author: R. David Murray (r.david.murray) * (Python committer) Date: 2013-06-12 12:53
The linked code does something different.  I believe the title of this issue is incorrect for the implicitly suggested enhancement.  I also suspect the suggested enhancement (to the extent that I understand it) is not ripe for stdlib inclusion, but I'll leave that up to Michael.
msg191025 - (view) Author: Michael Foord (michael.foord) * (Python committer) Date: 2013-06-12 12:58
The load_tests protocol is already the intended way for test writers to customize discovery. The problem, as issue 16662 states, is that load_tests is not invoked for packages by default. Fixing that is the right fix.

I'm rejecting this issue in favour of 16662.
msg191028 - (view) Author: (vila) Date: 2013-06-12 13:59
> The linked code does something different.

Right, it addressed other issues encountered in that project:
1 - the need for different paterns for files and directories (http://bugs.python.org/issue16662),
2 - handling import errors at load time (http://bugs.python.org/issue7559 as Robert told me),
3 - changing discovery policy at package level
4 - not importing test files (project specific)

The most blocking issue in that project was that there was no way to address (3). If that's fixed (and (1) as well) with http://bugs.python.org/issue16662, I'm fine with that, I'll be able to build the specifics for that project on top of it.
History
Date User Action Args
2022-04-11 14:57:46adminsetgithub: 62398
2013-06-12 13:59:17vilasetmessages: + msg191028
2013-06-12 12:58:23michael.foordsetstatus: open -> closed
messages: + msg191025

assignee: michael.foord
resolution: rejected
stage: resolved
2013-06-12 12:53:38r.david.murraysetnosy: + r.david.murray, michael.foord
messages: + msg191023
2013-06-12 12:30:14barrysetnosy: + barry
2013-06-12 08:07:05rbcollinssetmessages: + msg191017
2013-06-12 08:04:07rbcollinssetnosy: + rbcollins
messages: + msg191016
2013-06-12 08:01:19vilacreate