Title: unittest discover does not work with implicit namespaces
Type: behavior Stage: patch review
Components: Library (Lib) Versions: Python 3.8, Python 3.7
Status: open Resolution:
Dependencies: Superseder:
Assigned To: Nosy List: Simon Fagerholm, eamanu, eric.smith, martin.panter, terry.reedy
Priority: normal Keywords: patch, patch, patch, patch

Created on 2018-12-30 09:32 by Simon Fagerholm, last changed 2019-01-04 19:28 by terry.reedy.

Pull Requests
URL Status Linked Edit
PR 11364 open python-dev, 2018-12-30 09:53
PR 11364 python-dev, 2018-12-30 09:53
PR 11364 open python-dev, 2018-12-30 09:53
PR 11364 open python-dev, 2018-12-30 09:53
Messages (6)
msg332748 - (view) Author: Simon Fagerholm (Simon Fagerholm) * Date: 2018-12-30 09:32
When "python -m unittest discover" is run in a folder that is an implicit namespace package with the structure as below, no tests are discovered.
The condition that the tests must be importable from the top level directory is fulfilled and has been tested by importing the tests from the top level.

I did some investigating and have a PR underway that seems to fix it

Example project structure is:
├── requirements.txt
├── tests
    ├── unit
    │   └──
msg332750 - (view) Author: Simon Fagerholm (Simon Fagerholm) * Date: 2018-12-30 10:02
Issue originally from SO:
msg332768 - (view) Author: Martin Panter (martin.panter) * (Python committer) Date: 2018-12-30 22:29
Is this related to Issue 23882? That one is about making discovery work when “” files are removed.
msg332770 - (view) Author: Simon Fagerholm (Simon Fagerholm) * Date: 2018-12-30 22:56
Martin: Yeah, they same to be same! Can't believe I didn't find it
msg332787 - (view) Author: Emmanuel Arias (eamanu) * Date: 2018-12-31 02:13

IMO its a good propose. You will have to modify some tests.
msg332992 - (view) Author: Terry J. Reedy (terry.reedy) * (Python committer) Date: 2019-01-04 19:28
If this is truly a duplicate, this should be closed and the issue number in the pr title changed to 23882.  Any reviewer should look at both proposed fixes, as they are not the same.  The other patch has what looks like the beginning of a test.
Date User Action Args
2019-01-04 19:28:19terry.reedysetkeywords: patch, patch, patch, patch
nosy: + terry.reedy
messages: + msg332992

2018-12-31 02:13:19eamanusetnosy: + eamanu

messages: + msg332787
versions: + Python 3.8
2018-12-30 22:56:41Simon Fagerholmsetmessages: + msg332770
2018-12-30 22:29:01martin.pantersetkeywords: patch, patch, patch, patch
nosy: + martin.panter
messages: + msg332768

2018-12-30 11:16:16eric.smithsetkeywords: patch, patch, patch, patch
nosy: + eric.smith
2018-12-30 10:02:20Simon Fagerholmsetmessages: + msg332750
2018-12-30 09:53:21python-devsetkeywords: + patch
stage: patch review
pull_requests: + pull_request10694
2018-12-30 09:53:17python-devsetkeywords: + patch
stage: (no value)
pull_requests: + pull_request10693
2018-12-30 09:53:15python-devsetkeywords: + patch
stage: (no value)
pull_requests: + pull_request10692
2018-12-30 09:53:11python-devsetkeywords: + patch
stage: (no value)
pull_requests: + pull_request10691
2018-12-30 09:32:16Simon Fagerholmcreate