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 does not work with implicit namespaces
Type: behavior Stage: resolved
Components: Library (Lib) Versions: Python 3.8, Python 3.7
process
Status: closed Resolution: duplicate
Dependencies: Superseder: unittest discovery doesn't detect namespace packages when given no parameters
View: 23882
Assigned To: Nosy List: Simon Fagerholm, eamanu, eric.smith, martin.panter, pconnell, rgammans, terry.reedy
Priority: normal Keywords: patch, patch, patch, patch

Created on 2018-12-30 09:32 by Simon Fagerholm, last changed 2022-04-11 14:59 by admin. This issue is now closed.

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
├── main.py
├── tests
    ├── unit
    │   └── test_thing1.py
    └── integration.py
        └── test_integration_thing1.py
msg332750 - (view) Author: Simon Fagerholm (Simon Fagerholm) * Date: 2018-12-30 10:02
Issue originally from SO: https://stackoverflow.com/questions/46976256/recursive-unittest-discovery-with-python3-and-without-init-py-files
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 “__init__.py” 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
Hi!

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.
History
Date User Action Args
2022-04-11 14:59:09adminsetgithub: 79798
2020-07-19 03:49:02methanesetkeywords: patch, patch, patch, patch
status: open -> closed
superseder: unittest discovery doesn't detect namespace packages when given no parameters
resolution: duplicate
stage: patch review -> resolved
2019-10-28 20:48:34pconnellsetnosy: + pconnell
2019-08-19 21:42:26rgammanssetnosy: + rgammans
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