Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork33.3k
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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Uh oh!
There was an error while loading.Please reload this page.
Conversation
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.
| classExtendPathBaseTests(unittest.TestCase): | ||
| deftest_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)) | ||
| deftest_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.
| deftest_parent_package_raise_key_error(self): | |
| deftest_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 sureKeyError is raised, so the name of the test is confusing.
| name='foo.bar' | ||
| self.assertEqual(['path'],pkgutil.extend_path(path,name)) | ||
| deftest_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.
| deftest_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 | ||
| importfoo |
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 leavesys.modules dirty from this test. Use the helper functions intest.support to make sure this method cleans up after itself.
bedevere-bot commentedJun 9, 2023
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. |
Uh oh!
There was an error while loading.Please reload this page.
Actually, there are some tests for extend_path already (seehttps://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