-
-
Notifications
You must be signed in to change notification settings - Fork 32k
gh-59022: add tests to extend_path #12871
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
Conversation
cc @ericvsmith |
Would anybody mind to review and possibly merge this PR? |
@vsajip, @brettcannon, could you review and possibly merge this PR, please? (as the ones who committed into |
I'm rather swamped right now, so it might be a while (especially since I want to deprecate the entire |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The tests have some misleading names and they are not cleaning up after themselves appropriately.
@@ -489,6 +489,61 @@ def test_mixed_namespace(self): | |||
# XXX: test .pkg files | |||
|
|||
|
|||
class ExtendPathBaseTests(unittest.TestCase): | |||
def test_input_type_invalid(self): | |||
# path should be list instead of string |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Comments should be complete sentences.
name = 'foo' | ||
self.assertEqual('path', pkgutil.extend_path(path, name)) | ||
|
||
def test_parent_package_raise_key_error(self): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
def test_parent_package_raise_key_error(self): | |
def test_parent_package_raises_key_error(self): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There's nothing here making sure KeyError
is raised, so the name of the test is confusing.
name = 'foo.bar' | ||
self.assertEqual(['path'], pkgutil.extend_path(path, name)) | ||
|
||
def test_parent_package_raise_attr_error(self): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The name doesn't match what seems to be tested.
|
||
def test_extend_path_files(self): | ||
# create foo/bar.py | ||
self.dirname = tempfile.mkdtemp() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There's no cleanup of the temporary directory.
f = open(os.path.join(package_path, 'bar.py'), "w") | ||
f.close() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use a context manager and write a comment in the file as to the purpose of the file existing.
f = open(os.path.join(package_path, 'bar.py'), "w") | ||
f.close() | ||
# Search valid or invalid module | ||
import foo |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This will leave sys.modules
dirty from this test. Use the helper functions in test.support
to make sure this method cleans up after itself.
A Python core developer has requested some changes be made to your pull request before we can consider merging it. If you could please address their requests along with any other requests in other reviews from core developers that would be appreciated. Once you have made the requested changes, please leave a comment on this pull request containing the phrase |
Do we close this or do we remove the pending label? It's been almost 100 days. |
Closing due to inactivity. |
Actually, there are some tests for extend_path already (see https://github.com/python/cpython/blob/master/Lib/test/test_pkgutil.py#L235). I add some tests for it anyway. However, I didn't test every line of the code in the extend_path function.
https://bugs.python.org/issue14817