-
-
Notifications
You must be signed in to change notification settings - Fork 420
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
utils test coverage improvements #2283
utils test coverage improvements #2283
Conversation
Codecov ReportAll modified lines are covered by tests ✅
... and 18 files with indirect coverage changes 📢 Thoughts on this report? Let us know!. |
634df8d
to
2e880be
Compare
…pdm.utils.create_tracked_tempdir`
d9f082a
to
5742c09
Compare
d0e2b67
to
f78dc84
Compare
… `pdm.utils.get_trusted_hosts`
ce2f514
to
bafd974
Compare
@frostming This PR is complete, including the news fragment. It adds 8% to code coverage in So existing code coverage on
With this PR the measurement is:
|
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.
Cool, LGTM 🎉
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.
Please fix the test failures on older Python versions and Windows.
src/pdm/utils.py
Outdated
for item in items: | ||
new_items.extend([item, sep]) | ||
return new_items[:-1] | ||
return list(iter_chain.from_iterable(iter_product(items, [sep])))[:-1] |
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 brings more burden to understand, I prefer to keep the old code.
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.
OK, no problem. Will revert
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.
These test failures relate to path processing, which obviously works differently on Windows and POSIX. I'll need to revisit some of the test data here.
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.
@frostming I think I've fixed the test failures. There were two issues here: (1) incompatibility in test path instantiation between POSIX and Windows platforms which affected utils.get_venv_like_prefix
and utils.path_to_url
, (2) incompatibility in path equality checking between pre-Python 3.12.x and Python 3.12.x versions which affected utils.get_venv_like_prefix
.
I have Python 3.12.a01 installed via pyenv
, but was unable to install PDM(2.9.3) due to an error, so could not test the changes locally in 3.12. But they should now work 🤞
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.
path comparison is still failing. Thanks
Will be pushing an update in a few days, hopefully will fix all of the Windows failures. |
OK, I might just skip tests for |
Tests updated to skip some for Windows. |
|
||
def test_non_windows_localhost_local_file_url(self): | ||
with mock.patch("pdm.utils.sys.platform", "non_windows"): | ||
assert utils.url_to_path("file://localhost/local/file/path") == "/local/file/path" |
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.
Maybe skip it on windows and add another one for Windows only.
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.
Np.
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.
OK, I've added a single Windows-only test case for utils.url_to_path
testing the conversion of a localhost local file URL to a Windows path. I hope this works - I don't use Windows and don't have access to a Windows Python environment, so it is tricky for me to test this. But I am expecting that on Windows this URL -> path conversion is valid via utils.url_to_path
:
file://localhost/local/file/path -> C:/local/file/path
[?]
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.
Amended the expected path here, trying again.
db85d66
to
286376b
Compare
fix failing `url_to_path` test cases Co-authored-by: Frost Ming <[email protected]>
tweak `utils.url_to_path`test case skipping Co-authored-by: Frost Ming <[email protected]>
@frostming Assuming this now passes, should I rebase some commits to squash/tidy up? |
We will squash when merge |
* Update project TOML to add test coverage entrypoint + add tests for `pdm.utils.create_tracked_tempdir` * Add tests for `pdm.utils.get_trusted_hosts` * Add tests for `pdm.utils.url_without_fragments` * Add tests for `pdm.utils.join_list_with` * Add a parameterised fixture for repository configs + update tests for `pdm.utils.get_trusted_hosts` * Add tests for `pdm.utils.get_user_email_from_git` * Add tests for `pdm.utils.add_ssh_scheme_to_git_uri` * Add tests for `pdm.utils.path_to_url` * Add tests for `pdm.utils.path_replace` * Add tests for `pdm.utils.is_path_relative_to` * Fix test name typo for `utils.expand_env_vars_in_auth` * Add tests for `utils.get_venv_like_prefix` * Add tests for `utils.get_rev_from_url` * Correct test case input for `utils.add_ssh_scheme_to_uri` * Add tests for `utils.url_to_path` * Add tests for `utils.normalize_name` * Add tests for `utils.is_editable` * Add news fragment for issue #2273 * Revert changes to `pdm.utils.join_list_with` * Amend tests for `pdm.utils.get_venv_like_prefix` to make them platform- and Python-compatible * Amend tests for `pdm.utils.path_to_url` to make them platform-compatible * Tweak `conftest._PathFactory.get_py_compatible_mock_path` - amend Python version check * Tweak some `utils` tests to skip on Windows + minor refactoring of some fixtures * Fix path fixtures in `conftest` + add Windows-only test case for `utils.url_to_path` * Update tests/test_utils.py fix failing `url_to_path` test cases Co-authored-by: Frost Ming <[email protected]> * Update tests/test_utils.py tweak `utils.url_to_path`test case skipping Co-authored-by: Frost Ming <[email protected]> * Apply suggestions from code review --------- Co-authored-by: Frost Ming <[email protected]> Signed-off-by: Frost Ming <[email protected]>
Addresses #2273
Pull Request Checklist
news/
describing what is new.Describe what you have changed in this PR.
pyproject.toml
to add a test coverage entrypointpdm.utils