Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

load_tests not invoked in root __init__.py when start=package root #66647

Closed
rbtcollins opened this issue Sep 22, 2014 · 9 comments
Closed

load_tests not invoked in root __init__.py when start=package root #66647

rbtcollins opened this issue Sep 22, 2014 · 9 comments
Labels
type-bug An unexpected behavior, bug, or error

Comments

@rbtcollins
Copy link
Member

BPO 22457
Nosy @rbtcollins, @ezio-melotti, @voidspace
Files
  • issue22457.patch
  • issue22457.patch
  • issue22457.patch
  • issue22457.patch
  • Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.

    Show more details

    GitHub fields:

    assignee = None
    closed_at = <Date 2014-11-04.14:10:28.751>
    created_at = <Date 2014-09-22.03:47:54.395>
    labels = ['type-bug']
    title = 'load_tests not invoked in root __init__.py when start=package root'
    updated_at = <Date 2014-11-04.14:44:17.394>
    user = 'https://github.com/rbtcollins'

    bugs.python.org fields:

    activity = <Date 2014-11-04.14:44:17.394>
    actor = 'python-dev'
    assignee = 'none'
    closed = True
    closed_date = <Date 2014-11-04.14:10:28.751>
    closer = 'python-dev'
    components = []
    creation = <Date 2014-09-22.03:47:54.395>
    creator = 'rbcollins'
    dependencies = []
    files = ['36694', '36973', '37071', '37118']
    hgrepos = []
    issue_num = 22457
    keywords = ['patch']
    message_count = 9.0
    messages = ['227250', '227327', '227499', '229702', '230254', '230315', '230617', '230625', '230627']
    nosy_count = 5.0
    nosy_names = ['rbcollins', 'ezio.melotti', 'zzzeek', 'michael.foord', 'python-dev']
    pr_nums = []
    priority = 'normal'
    resolution = 'fixed'
    stage = 'resolved'
    status = 'closed'
    superseder = None
    type = 'behavior'
    url = 'https://bugs.python.org/issue22457'
    versions = ['Python 3.5']

    @rbtcollins
    Copy link
    Member Author

    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

    @rbtcollins
    Copy link
    Member Author

    This should fix this issue :)

    @rbtcollins
    Copy link
    Member Author

    Updated patch - fixes windows tests for this patch.

    @rbtcollins
    Copy link
    Member Author

    Updated patch.

    @rbtcollins
    Copy link
    Member Author

    Updated patch, after other recent conflicting changes.

    @rbtcollins rbtcollins added the type-bug An unexpected behavior, bug, or error label Oct 30, 2014
    @rbtcollins
    Copy link
    Member Author

    (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).

    @voidspace
    Copy link
    Contributor

    With one minor doc change (break up the really long sentence), this looks good to go to me.

    @python-dev
    Copy link
    Mannequin

    python-dev mannequin commented Nov 4, 2014

    New changeset ce0dd5e4b801 by Robert Collins in branch 'default':
    Close bpo-22457: Honour load_tests in the start_dir of discovery.
    https://hg.python.org/cpython/rev/ce0dd5e4b801

    @python-dev python-dev mannequin closed this as completed Nov 4, 2014
    @python-dev
    Copy link
    Mannequin

    python-dev mannequin commented Nov 4, 2014

    New changeset 2aac2d76035e by Robert Collins in branch 'default':
    Fix regression in bpo-22457 fix.
    https://hg.python.org/cpython/rev/2aac2d76035e

    @ezio-melotti ezio-melotti transferred this issue from another repository Apr 10, 2022
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
    Labels
    type-bug An unexpected behavior, bug, or error
    Projects
    None yet
    Development

    No branches or pull requests

    2 participants