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: load_tests not invoked in root __init__.py when start=package root
Type: behavior Stage: resolved
Components: Versions: Python 3.5
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: Nosy List: ezio.melotti, michael.foord, python-dev, rbcollins, zzzeek
Priority: normal Keywords: patch

Created on 2014-09-22 03:47 by rbcollins, last changed 2022-04-11 14:58 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
issue22457.patch rbcollins, 2014-09-23 08:29 review
issue22457.patch rbcollins, 2014-10-19 23:10 review
issue22457.patch rbcollins, 2014-10-30 03:14 review
issue22457.patch rbcollins, 2014-11-03 09:38 review
Messages (9)
msg227250 - (view) Author: Robert Collins (rbcollins) * (Python committer) Date: 2014-09-22 03:47
python -m unittest discover -t . foo

where foo is a package

will not trigger load_tests in foo/__init__.py.

To reproduce:

mkdir -p demo/tests
cd demo
cat <<EOF > tests/__init__.py
import sys
import os

def load_tests(loader, tests, pattern):
    print("HI WE ARE LOADING!")
    this_dir = os.path.dirname(__file__)
    tests.addTest(loader.discover(start_dir=this_dir, pattern=pattern))
    return tests
EOF

python -m unittest discover -t . tests
msg227327 - (view) Author: Robert Collins (rbcollins) * (Python committer) Date: 2014-09-23 08:29
This should fix this issue :)
msg227499 - (view) Author: Robert Collins (rbcollins) * (Python committer) Date: 2014-09-25 01:06
Updated patch - fixes windows tests for this patch.
msg229702 - (view) Author: Robert Collins (rbcollins) * (Python committer) Date: 2014-10-19 23:10
Updated patch.
msg230254 - (view) Author: Robert Collins (rbcollins) * (Python committer) Date: 2014-10-30 03:14
Updated patch, after other recent conflicting changes.
msg230315 - (view) Author: Robert Collins (rbcollins) * (Python committer) Date: 2014-10-31 01:00
(Pinging for reviews - I'm going to time out and land this early next week if I can't get a review on it, since this is actually a fairly significant oversight and I don't want unittest2 to run ahead of the stdlib - that way leads unmaintainable madness).
msg230617 - (view) Author: Michael Foord (michael.foord) * (Python committer) Date: 2014-11-04 11:45
With one minor doc change (break up the really long sentence), this looks good to go to me.
msg230625 - (view) Author: Roundup Robot (python-dev) (Python triager) Date: 2014-11-04 14:10
New changeset ce0dd5e4b801 by Robert Collins in branch 'default':
Close #22457: Honour load_tests in the start_dir of discovery.
https://hg.python.org/cpython/rev/ce0dd5e4b801
msg230627 - (view) Author: Roundup Robot (python-dev) (Python triager) Date: 2014-11-04 14:44
New changeset 2aac2d76035e by Robert Collins in branch 'default':
Fix regression in issue 22457 fix.
https://hg.python.org/cpython/rev/2aac2d76035e
History
Date User Action Args
2022-04-11 14:58:08adminsetgithub: 66647
2014-11-04 14:44:17python-devsetmessages: + msg230627
2014-11-04 14:10:28python-devsetstatus: open -> closed

nosy: + python-dev
messages: + msg230625

resolution: fixed
stage: resolved
2014-11-04 11:45:59michael.foordsetmessages: + msg230617
2014-11-03 09:38:14rbcollinssetfiles: + issue22457.patch
2014-10-31 01:00:59rbcollinssetmessages: + msg230315
2014-10-30 03:19:57rbcollinssettype: behavior
versions: + Python 3.5
2014-10-30 03:14:47rbcollinssetfiles: + issue22457.patch

messages: + msg230254
2014-10-19 23:10:23rbcollinssetfiles: + issue22457.patch

messages: + msg229702
2014-10-19 23:09:33rbcollinssetfiles: - issue22457.diff
2014-09-25 01:06:11rbcollinssetfiles: + issue22457.diff

messages: + msg227499
2014-09-23 08:29:23rbcollinssetfiles: + issue22457.patch
keywords: + patch
messages: + msg227327
2014-09-22 07:40:26ned.deilysetnosy: + ezio.melotti, michael.foord
2014-09-22 04:16:40zzzeeksetnosy: + zzzeek
2014-09-22 03:47:54rbcollinscreate