Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
This pull request includes several changes to the
swanlab/package.py
file and the associated unit tests to improve the handling of.netrc
files and ensure that only one host entry is maintained. The most important changes include the addition of a new function to get the.netrc
file path, updates to existing functions to use this new function, and enhancements to the unit tests to verify the new behavior.Enhancements to
.netrc
file handling:swanlab/package.py
: Added a new functionget_nrc_path()
to obtain the.netrc
file path.swanlab/package.py
: Updated theget_key()
andsave_key()
functions to use the newget_nrc_path()
function for obtaining the.netrc
file path. [1] [2]swanlab/package.py
: Modified thesave_key()
function to avoid writing duplicate host entries and ensure only one host entry is maintained.Improvements to unit tests:
test/unit/test_package.py
: Enhanced thetest_ok
test to verify that only one host entry is maintained after saving a new host.test/unit/test_package.py
: Added a new testtest_duplicate
to check the behavior of saving duplicate entries, ensuring that the.netrc
file is not modified unnecessarily.closes #797