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

Refactor the test_runpy walk_package support code into a common location #59581

Open
cjerdonek opened this issue Jul 17, 2012 · 8 comments
Open
Labels
easy tests Tests in the Lib/test dir type-feature A feature request or enhancement

Comments

@cjerdonek
Copy link
Member

BPO 15376
Nosy @ncoghlan, @cjerdonek, @ericsnowcurrently
Dependencies
  • bpo-15403: Refactor package creation support code into a common location
  • bpo-15415: Add temp_dir() and change_cwd() to test.support
  • 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 = None
    created_at = <Date 2012-07-17.07:10:48.923>
    labels = ['easy', 'type-feature', 'tests']
    title = 'Refactor the test_runpy walk_package support code into a common location'
    updated_at = <Date 2019-03-15.21:57:39.861>
    user = 'https://github.com/cjerdonek'

    bugs.python.org fields:

    activity = <Date 2019-03-15.21:57:39.861>
    actor = 'BreamoreBoy'
    assignee = 'none'
    closed = False
    closed_date = None
    closer = None
    components = ['Tests']
    creation = <Date 2012-07-17.07:10:48.923>
    creator = 'chris.jerdonek'
    dependencies = ['15403', '15415']
    files = []
    hgrepos = []
    issue_num = 15376
    keywords = ['easy']
    message_count = 8.0
    messages = ['165683', '165702', '165911', '166207', '166450', '193824', '223521', '243530']
    nosy_count = 4.0
    nosy_names = ['ncoghlan', 'chris.jerdonek', 'eric.snow', 'bobcatfish']
    pr_nums = []
    priority = 'normal'
    resolution = None
    stage = None
    status = 'open'
    superseder = None
    type = 'enhancement'
    url = 'https://bugs.python.org/issue15376'
    versions = ['Python 3.5']

    @cjerdonek
    Copy link
    Member Author

    This issue is to refactor the create-package code in test_runpy into a helper module, as suggested in bpo-15358.

    This is a prerequisite to moving the pkgutil.walk_package() tests from test_runpy into test_pkgutil.

    @cjerdonek cjerdonek added tests Tests in the Lib/test dir easy labels Jul 17, 2012
    @ncoghlan
    Copy link
    Contributor

    One trap to watch out for: it's best to call os.path.realpath() on any temporary directories created, since the interpreter tends to do that internally.

    I'd previously dealt with this in script_helper.temp_dir, but it came up again when I tightened up the runpy.run_module tests to actually check that __file__ ended up with the expected value.

    @cjerdonek
    Copy link
    Member Author

    I'm going to address this issue in parts to make it easier to review and see what is going on.

    The first patch I'm uploading shortly here: bpo-15403. That issue I created to address just the "file creation" part of the code.

    The approach I'm taking is to keep the file creation code decoupled from the temp directory, sys.path, and import code. My plan is to address the latter in separate patches by creating or modifying existing test support context managers, as necessary.

    @cjerdonek cjerdonek changed the title Refactor the create-package code in test_runpy into a helper module Refactor the test_runpy walk_package support code into a common location Jul 20, 2012
    @cjerdonek
    Copy link
    Member Author

    I created bpo-15415 and uploaded a patch there with this issue in mind.

    test_runpy contains supporting _make_pkg() and _del_pkg() methods that,
    among other things, create and delete a temp directory. That logic
    would be better handled by a temp directory context manager.

    The patch uploaded to bpo-15415 creates such a context manager and
    also unit-tests it. It also reduces the duplication of temp
    directory logic between test/script_helper.py and test/support.py.

    @cjerdonek
    Copy link
    Member Author

    Hi Nick, I was wondering if you'd have time to take a look at the patches I've uploaded to bpo-15403 and bpo-15415 at some point.

    Once those are addressed, I think we will be in a much better position to address most of this issue.

    @ncoghlan ncoghlan self-assigned this Jul 30, 2012
    @ncoghlan
    Copy link
    Contributor

    test.support is now a subpackage in both 3.3 and default, but test.support.package_helper still needs to be created (see comments on bpo-15403)

    @BreamoreBoy
    Copy link
    Mannequin

    BreamoreBoy mannequin commented Jul 20, 2014

    The chain of dependencies goes from here to bpo-15403, bpo-18576 and back here. How do we break this loop?

    @BreamoreBoy BreamoreBoy mannequin added the type-feature A feature request or enhancement label Jul 20, 2014
    @bobcatfish
    Copy link
    Mannequin

    bobcatfish mannequin commented May 18, 2015

    @breamoreboy, it looks like the next step would be to revisit bpo-15403 and go through the steps outlined by @ncoghlan.

    @ncoghlan ncoghlan removed their assignment Jun 28, 2015
    @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
    easy tests Tests in the Lib/test dir type-feature A feature request or enhancement
    Projects
    None yet
    Development

    No branches or pull requests

    2 participants