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 recurse into packages which are already in sys.path
Type: enhancement Stage:
Components: Versions: Python 3.3
process
Status: open Resolution:
Dependencies: Superseder:
Assigned To: Nosy List: Calvin.Spealman, ezio.melotti, michael.foord
Priority: normal Keywords:

Created on 2011-03-26 14:36 by Calvin.Spealman, last changed 2022-04-11 14:57 by admin.

Messages (5)
msg132242 - (view) Author: Calvin Spealman (Calvin.Spealman) Date: 2011-03-26 14:36
For example, if I had a project with a "src/" directory and inside that directory is a package named "foo", then I can run "python3 -m unittest discover -s ." and the tests will be not be found, but I can run "python3 -m unittest discover -s src/" and the tests in the foo package are run. This is because it can only find things which are in the python path, but if I have src/ on the path (I ran "add2virtualenv src/" at some point) then discover should know it can traverse inside this directory.
msg132271 - (view) Author: Michael Foord (michael.foord) * (Python committer) Date: 2011-03-26 20:06
Going into multiple directories on the path would make discovery more complex (but isn't out of the question).

To be compatible with nose test discovery it is likely that we will special case an "src" directory anyway though (as it is a relatively common pattern to put code into an "src" directory).
msg132274 - (view) Author: Calvin Spealman (Calvin.Spealman) Date: 2011-03-26 21:30
Doesn't it already go into multiple directories? Isn't that a requirement of a recursive directory walk, which I understand discover does?

I am also thinking the current documentation just doesn't make these details clear, so should that be another ticket if I think those should change for the 3.2 docs to clarify the current behavior?
msg132279 - (view) Author: Michael Foord (michael.foord) * (Python committer) Date: 2011-03-26 22:56
Discover does recurse into directories - but only packages, so the algorithm for importing them is trivial. You're suggesting enhancing that to multiple strategies (checking non package directories to see if they are on the path and then recursing into them as well). I can well believe the docs could do with clarifying though - and a patch for that would be awesome.
msg132280 - (view) Author: Michael Foord (michael.foord) * (Python committer) Date: 2011-03-26 22:58
Calvin, note that the modification you suggest is not a *great* complication to the discovery algorithm (just "some" complication); so I'll consider it.
History
Date User Action Args
2022-04-11 14:57:15adminsetgithub: 55892
2011-03-26 22:58:09michael.foordsetmessages: + msg132280
2011-03-26 22:56:13michael.foordsetmessages: + msg132279
2011-03-26 21:30:22Calvin.Spealmansetmessages: + msg132274
2011-03-26 20:06:52michael.foordsetversions: + Python 3.3, - Python 3.2
2011-03-26 20:06:47michael.foordsetmessages: + msg132271
2011-03-26 19:01:21ezio.melottisetnosy: + ezio.melotti, michael.foord
2011-03-26 14:36:41Calvin.Spealmancreate