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

Make full use of test discovery in test subpackages #66201

Closed
zware opened this issue Jul 17, 2014 · 9 comments
Closed

Make full use of test discovery in test subpackages #66201

zware opened this issue Jul 17, 2014 · 9 comments
Assignees
Labels
tests Tests in the Lib/test dir type-feature A feature request or enhancement

Comments

@zware
Copy link
Member

zware commented Jul 17, 2014

BPO 22002
Nosy @brettcannon, @vstinner, @ezio-melotti, @bitdancer, @berkerpeksag, @zware, @serhiy-storchaka
Files
  • package_discovery.diff: Patch against 3.4
  • 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 = 'https://github.com/zware'
    closed_at = <Date 2014-07-23.17:07:11.687>
    created_at = <Date 2014-07-17.20:09:20.194>
    labels = ['type-feature', 'tests']
    title = 'Make full use of test discovery in test subpackages'
    updated_at = <Date 2014-07-23.17:11:04.153>
    user = 'https://github.com/zware'

    bugs.python.org fields:

    activity = <Date 2014-07-23.17:11:04.153>
    actor = 'zach.ware'
    assignee = 'zach.ware'
    closed = True
    closed_date = <Date 2014-07-23.17:07:11.687>
    closer = 'python-dev'
    components = ['Tests']
    creation = <Date 2014-07-17.20:09:20.194>
    creator = 'zach.ware'
    dependencies = []
    files = ['35987']
    hgrepos = []
    issue_num = 22002
    keywords = ['patch']
    message_count = 9.0
    messages = ['223366', '223407', '223517', '223536', '223576', '223577', '223690', '223745', '223747']
    nosy_count = 9.0
    nosy_names = ['brett.cannon', 'vstinner', 'ezio.melotti', 'r.david.murray', 'BreamoreBoy', 'python-dev', 'berker.peksag', 'zach.ware', 'serhiy.storchaka']
    pr_nums = []
    priority = 'normal'
    resolution = 'fixed'
    stage = 'resolved'
    status = 'closed'
    superseder = None
    type = 'enhancement'
    url = 'https://bugs.python.org/issue22002'
    versions = ['Python 3.4', 'Python 3.5']

    @zware
    Copy link
    Member Author

    zware commented Jul 17, 2014

    Here's a patch against 3.4 implementing Serhiy's suggestion in msg223277 and taking it a step further, actually using test discovery in all of the test.test_* subpackages.

    To reduce duplication, the patch adds a 'load_package_tests' function to test.support, which is then used in each of the subpackages' load_tests function.

    test_json and test_tools should have no visible changes from this patch. test_asyncio and test_email do have slight differences, but only in verbosity level: pre-patch, python -m test.test_(asyncio|email) runs at verbosity=2 (support.run_unittest default); with patch, they run at verbosity=1 (unittest default). test_asyncio also reports one more skipped test on Windows, due to a module that raises SkipTest on import.

    @brett: test_importlib sees the most changes, and I'd like to be sure that things are as you expect them to be. It looks like all of the test_suite() stuff is unused leftovers from when "test_importlib" was "importlib.test" and that test_importlib has actually been relying on unittest discovery (but bypassing load_tests and thereby not working with python -m unittest test.test_importlib), but I'd like confirmation on that.

    A nice bonus with this patch is that (for example) python -m test.test_importlib.source works, testing just the named test_importlib subpackage.

    @zware zware added tests Tests in the Lib/test dir type-feature A feature request or enhancement labels Jul 17, 2014
    @brettcannon
    Copy link
    Member

    I can confirm everything you said is accurate, Zachary. And I very much look forward to the results of the patch. =)

    @bitdancer
    Copy link
    Member

    I have no problem with the change to test_email. (I could have sworn I tried unittest.main() in __main__ when I set it up, but I must have screwed something up).

    I didn't go over the patch line by line, but it looks good to me.

    @BreamoreBoy
    Copy link
    Mannequin

    BreamoreBoy mannequin commented Jul 20, 2014

    I'm getting lost in all the enhancement requests for tests. How does this relate to e.g. 16748 or 10572?

    @zware
    Copy link
    Member Author

    zware commented Jul 21, 2014

    Thank you, Brett and David.

    @mark: This issue is a continuation of the bpo-16748 effort (bpo-16748 is a meta-issue for this kind of thing) and unrelated to bpo-10572 (though this will add a feature to test.support that can be useful for the scattered test packages).

    @zware
    Copy link
    Member Author

    zware commented Jul 21, 2014

    Victor, could you give me a yay or nay on the test_asyncio change?

    @serhiy-storchaka
    Copy link
    Member

    Nice. Could you please comment multiple dirname()-s in load_package_tests() as it done for basename in Lib/test/test_tools/init.py?

    @python-dev
    Copy link
    Mannequin

    python-dev mannequin commented Jul 23, 2014

    New changeset 4f9f7e0fe1fd by Zachary Ware in branch '3.4':
    Issue bpo-22002: Make full use of test discovery in test sub-packages.
    http://hg.python.org/cpython/rev/4f9f7e0fe1fd

    New changeset 6298895a52de by Zachary Ware in branch 'default':
    Closes bpo-22002: Merge with 3.4
    http://hg.python.org/cpython/rev/6298895a52de

    @python-dev python-dev mannequin closed this as completed Jul 23, 2014
    @zware
    Copy link
    Member Author

    zware commented Jul 23, 2014

    Committed with a couple of changes from the posted patch: commented on the multiple dirname() calls as Serhiy suggested, removed the 'with DirsOnSysPath():' line since it turns out to be unnecessary when supplying top_level_dir to loader.discover(), and added some documentation for the new function to Doc/library/test.rst.

    Victor, I went ahead and did the change to test_asyncio since it looks like the tulip project test package doesn't actually have __init__.py or __main__.py, and thus should be no conflict. Please correct me if I'm wrong on that.

    Thanks for the reviews!

    @zware zware self-assigned this Jul 23, 2014
    @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
    tests Tests in the Lib/test dir type-feature A feature request or enhancement
    Projects
    None yet
    Development

    No branches or pull requests

    4 participants