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: pkgutil.extend_path has no tests
Type: enhancement Stage: patch review
Components: Tests Versions: Python 3.9, Python 3.8, Python 3.7
process
Status: open Resolution:
Dependencies: Superseder:
Assigned To: Nosy List: Arfrever, Windson Yang, eric.smith, pitrou
Priority: normal Keywords: easy, patch

Created on 2012-05-15 19:19 by eric.smith, last changed 2022-04-11 14:57 by admin.

Pull Requests
URL Status Linked Edit
PR 12871 open Windson Yang, 2019-04-18 03:14
Messages (10)
msg160751 - (view) Author: Eric V. Smith (eric.smith) * (Python committer) Date: 2012-05-15 19:19
Subject says it all.

There are also no tests of .pkg files.
msg160784 - (view) Author: Roundup Robot (python-dev) (Python triager) Date: 2012-05-16 00:46
New changeset 48cb6b67d306 by Eric V. Smith in branch '3.2':
Issue #14817: Add rudimentary tests for pkgutil.extend_path.
http://hg.python.org/cpython/rev/48cb6b67d306
msg160785 - (view) Author: Eric V. Smith (eric.smith) * (Python committer) Date: 2012-05-16 00:48
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.
msg160792 - (view) Author: Eric V. Smith (eric.smith) * (Python committer) Date: 2012-05-16 01:43
This code does not clean up correctly. It needs to remove the added modules in sys.modules. I'll eventually clean it up, once issue 14715 is addressed.
msg160809 - (view) Author: Antoine Pitrou (pitrou) * (Python committer) Date: 2012-05-16 07:54
This has broken all 3.x buildbots.
msg221843 - (view) Author: Mark Lawrence (BreamoreBoy) * Date: 2014-06-29 13:34
@Eric will you pick this up again?
msg338577 - (view) Author: Windson Yang (Windson Yang) * Date: 2019-03-22 02:00
I would like to work on this and make a PR.
msg338934 - (view) Author: Windson Yang (Windson Yang) * Date: 2019-03-27 01:55
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.
msg339764 - (view) Author: Joannah Nanjekye (nanjekyejoannah) * (Python committer) Date: 2019-04-09 15:26
@Windson please open a PR for review with your code.
msg340465 - (view) Author: Windson Yang (Windson Yang) * Date: 2019-04-18 03:16
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.
History
Date User Action Args
2022-04-11 14:57:30adminsetgithub: 59022
2019-07-29 18:36:31nanjekyejoannahsetnosy: - nanjekyejoannah
2019-04-18 03:16:13Windson Yangsetmessages: + msg340465
2019-04-18 03:14:51Windson Yangsetkeywords: + patch
stage: patch review
pull_requests: + pull_request12795
2019-04-09 15:26:31nanjekyejoannahsetnosy: + nanjekyejoannah
messages: + msg339764
2019-03-27 01:55:31Windson Yangsetmessages: + msg338934
2019-03-22 02:00:16Windson Yangsetversions: + Python 3.7, Python 3.8, Python 3.9
nosy: + Windson Yang

messages: + msg338577

type: enhancement
2019-03-16 00:05:34BreamoreBoysetnosy: - BreamoreBoy
2014-06-29 13:34:39BreamoreBoysetnosy: + BreamoreBoy
messages: + msg221843
2012-05-17 16:22:30Arfreversetnosy: + Arfrever
2012-05-16 07:54:26pitrousetnosy: + pitrou
messages: + msg160809
2012-05-16 01:43:21eric.smithsetmessages: + msg160792
2012-05-16 00:48:05eric.smithsetnosy: - python-dev
messages: + msg160785
2012-05-16 00:46:18python-devsetnosy: + python-dev
messages: + msg160784
2012-05-15 19:19:00eric.smithcreate