Thanks to visit codestin.com
Credit goes to github.com

Skip to content

pkgutil.extend_path has no tests #59022

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

Closed
ericvsmith opened this issue May 15, 2012 · 11 comments
Closed

pkgutil.extend_path has no tests #59022

ericvsmith opened this issue May 15, 2012 · 11 comments
Labels
3.7 (EOL) end of life 3.8 (EOL) end of life 3.9 only security fixes easy tests Tests in the Lib/test dir type-feature A feature request or enhancement

Comments

@ericvsmith
Copy link
Member

ericvsmith commented May 15, 2012

BPO 14817
Nosy @pitrou, @ericvsmith, @Windsooon
PRs
  • gh-59022: add tests to extend_path #12871
  • 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-05-15.19:19:00.156>
    labels = ['easy', 'type-feature', '3.8', '3.9', '3.7', 'tests']
    title = 'pkgutil.extend_path has no tests'
    updated_at = <Date 2019-07-29.18:36:31.538>
    user = 'https://github.com/ericvsmith'

    bugs.python.org fields:

    activity = <Date 2019-07-29.18:36:31.538>
    actor = 'nanjekyejoannah'
    assignee = 'none'
    closed = False
    closed_date = None
    closer = None
    components = ['Tests']
    creation = <Date 2012-05-15.19:19:00.156>
    creator = 'eric.smith'
    dependencies = []
    files = []
    hgrepos = []
    issue_num = 14817
    keywords = ['patch', 'easy']
    message_count = 10.0
    messages = ['160751', '160784', '160785', '160792', '160809', '221843', '338577', '338934', '339764', '340465']
    nosy_count = 4.0
    nosy_names = ['pitrou', 'eric.smith', 'Arfrever', 'Windson Yang']
    pr_nums = ['12871']
    priority = 'normal'
    resolution = None
    stage = 'patch review'
    status = 'open'
    superseder = None
    type = 'enhancement'
    url = 'https://bugs.python.org/issue14817'
    versions = ['Python 3.7', 'Python 3.8', 'Python 3.9']

    Linked PRs

    @ericvsmith
    Copy link
    Member Author

    Subject says it all.

    There are also no tests of .pkg files.

    @ericvsmith ericvsmith added tests Tests in the Lib/test dir easy labels May 15, 2012
    @python-dev
    Copy link
    Mannequin

    python-dev mannequin commented May 16, 2012

    New changeset 48cb6b67d306 by Eric V. Smith in branch '3.2':
    Issue bpo-14817: Add rudimentary tests for pkgutil.extend_path.
    http://hg.python.org/cpython/rev/48cb6b67d306

    @ericvsmith
    Copy link
    Member Author

    I'm going to leave this open until better tests are added. The one I did add it very simple, but it's good enough for the changes I'm about to make.

    @ericvsmith
    Copy link
    Member Author

    This code does not clean up correctly. It needs to remove the added modules in sys.modules. I'll eventually clean it up, once bpo-14715 is addressed.

    @pitrou
    Copy link
    Member

    pitrou commented May 16, 2012

    This has broken all 3.x buildbots.

    @BreamoreBoy
    Copy link
    Mannequin

    BreamoreBoy mannequin commented Jun 29, 2014

    @eric will you pick this up again?

    @Windsooon
    Copy link
    Mannequin

    Windsooon mannequin commented Mar 22, 2019

    I would like to work on this and make a PR.

    @Windsooon Windsooon mannequin added 3.7 (EOL) end of life 3.8 (EOL) end of life 3.9 only security fixes type-feature A feature request or enhancement labels Mar 22, 2019
    @Windsooon
    Copy link
    Mannequin

    Windsooon mannequin commented Mar 27, 2019

    My base idea would be some unittests for the function like:

    class ExtendPathBaseTests(unittest.TestCase):
        def test_input_string(self):
            path = 'path'
            name = 'foo'
            self.assertEqual('path', pkgutil.extend_path(path, name))
    
        def test_parent_package_raise_key_error(self):
            path = ['path']
            # sys.modules['foo'] raise KeyError
            name = 'foo.bar'
            self.assertEqual(['path'], pkgutil.extend_path(path, name))
    
        def test_parent_package_raise_attr_error(self):
            path = ['path']
            # datetime module don't have __path__ attr
            name = 'datetime.date'
            self.assertEqual(['path'], pkgutil.extend_path(path, name))

    I would move forward if we agreed.

    @nanjekyejoannah
    Copy link
    Contributor

    @windson please open a PR for review with your code.

    @Windsooon
    Copy link
    Mannequin

    Windsooon mannequin commented Apr 18, 2019

    I added some tests in the PR. Actually, there are some tests for extend_path already (see https://github.com/python/cpython/blob/master/Lib/test/test_pkgutil.py#L235). However, I didn't test every line of the code in the extend_path function.

    @ezio-melotti ezio-melotti transferred this issue from another repository Apr 10, 2022
    beachmachine added a commit to beachmachine/cpython that referenced this issue Jul 13, 2024
    This adds tests for the documented behaviour of `pkgutil.extend_path`
    regarding different argument types as well as for `*.pkg` files.
    beachmachine added a commit to beachmachine/cpython that referenced this issue Jul 13, 2024
    This adds tests for the documented behaviour of `pkgutil.extend_path`
    regarding different argument types as well as for `*.pkg` files.
    beachmachine added a commit to beachmachine/cpython that referenced this issue Jul 13, 2024
    This adds tests for the documented behaviour of `pkgutil.extend_path`
    regarding different argument types as well as for `*.pkg` files.
    beachmachine added a commit to beachmachine/cpython that referenced this issue Jul 13, 2024
    This adds tests for the documented behaviour of `pkgutil.extend_path`
    regarding different argument types as well as for `*.pkg` files.
    beachmachine added a commit to beachmachine/cpython that referenced this issue Jul 14, 2024
    encukou pushed a commit that referenced this issue Jul 16, 2024
    This adds tests for the documented behaviour of `pkgutil.extend_path`
    regarding different argument types as well as for `*.pkg` files.
    miss-islington pushed a commit to miss-islington/cpython that referenced this issue Jul 16, 2024
    pythonGH-121673)
    
    This adds tests for the documented behaviour of `pkgutil.extend_path`
    regarding different argument types as well as for `*.pkg` files.
    (cherry picked from commit 8f25321)
    
    Co-authored-by: Andreas Stocker <[email protected]>
    estyxx pushed a commit to estyxx/cpython that referenced this issue Jul 17, 2024
    …ythonGH-121673)
    
    This adds tests for the documented behaviour of `pkgutil.extend_path`
    regarding different argument types as well as for `*.pkg` files.
    miss-islington pushed a commit to miss-islington/cpython that referenced this issue Jul 18, 2024
    pythonGH-121673)
    
    This adds tests for the documented behaviour of `pkgutil.extend_path`
    regarding different argument types as well as for `*.pkg` files.
    (cherry picked from commit 8f25321)
    
    Co-authored-by: Andreas Stocker <[email protected]>
    miss-islington pushed a commit to miss-islington/cpython that referenced this issue Jul 18, 2024
    pythonGH-121673)
    
    This adds tests for the documented behaviour of `pkgutil.extend_path`
    regarding different argument types as well as for `*.pkg` files.
    (cherry picked from commit 8f25321)
    
    Co-authored-by: Andreas Stocker <[email protected]>
    encukou pushed a commit that referenced this issue Jul 19, 2024
    …H-121951)
    
    This adds tests for the documented behaviour of `pkgutil.extend_path`
    regarding different argument types as well as for `*.pkg` files.
    (cherry picked from commit 8f25321)
    
    Co-authored-by: Andreas Stocker <[email protected]>
    encukou pushed a commit that referenced this issue Jul 19, 2024
    …H-121950)
    
    This adds tests for the documented behaviour of `pkgutil.extend_path`
    regarding different argument types as well as for `*.pkg` files.
    (cherry picked from commit 8f25321)
    
    Co-authored-by: Andreas Stocker <[email protected]>
    @encukou
    Copy link
    Member

    encukou commented Jul 19, 2024

    Thank you!

    @encukou encukou closed this as completed Jul 19, 2024
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
    Labels
    3.7 (EOL) end of life 3.8 (EOL) end of life 3.9 only security fixes easy 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