-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
Display path relative to temporary repo when get/import-ing files #2798
Merged
+94
β3
Merged
Changes from 2 commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -16,7 +16,7 @@ | |||||
from dvc.utils.fs import get_inode | ||||||
from dvc.utils.fs import get_mtime_and_size | ||||||
from dvc.utils.fs import move | ||||||
from dvc.utils.fs import remove | ||||||
from dvc.utils.fs import path_isin, remove | ||||||
from tests.basic_env import TestDir | ||||||
from tests.utils import spy | ||||||
|
||||||
|
@@ -164,3 +164,49 @@ def test_remove(repo_dir): | |||||
|
||||||
remove(path_info) | ||||||
assert not os.path.isfile(path_info.fspath) | ||||||
|
||||||
|
||||||
@pytest.mark.parametrize( | ||||||
"parent", | ||||||
[ | ||||||
(os.path.join("path", "to", "")), | ||||||
(os.path.join("path", "to")), | ||||||
(os.path.join("path", "")), | ||||||
(os.path.join("path")), | ||||||
], | ||||||
) | ||||||
skshetry marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||
def test_path_isin_positive(parent): | ||||||
child = os.path.join("path", "to", "folder") | ||||||
assert path_isin(child, parent) | ||||||
|
||||||
|
||||||
def test_path_isin_on_same_path(): | ||||||
path = os.path.join("path", "to", "folder") | ||||||
path2 = os.path.join(path, "") | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fixed. |
||||||
|
||||||
assert not path_isin(path, path) | ||||||
assert not path_isin(path, path2) | ||||||
assert not path_isin(path2, path) | ||||||
assert not path_isin(path2, path2) | ||||||
|
||||||
|
||||||
def test_path_isin_on_common_substring_path(): | ||||||
path1 = os.path.join("path", "to", "folder1") | ||||||
path2 = os.path.join("path", "to", "folder") | ||||||
|
||||||
assert not path_isin(path1, path2) | ||||||
|
||||||
|
||||||
def test_path_isin_accepts_pathinfo(): | ||||||
child = os.path.join("path", "to", "folder") | ||||||
parent = PathInfo(child) / ".." | ||||||
|
||||||
assert path_isin(child, parent) | ||||||
assert not path_isin(parent, child) | ||||||
|
||||||
|
||||||
def test_path_isin_with_absolute_path(): | ||||||
parent = os.path.abspath("path") | ||||||
child = os.path.join(parent, "to", "folder") | ||||||
|
||||||
assert path_isin(child, parent) |
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.
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.
It should be
fspath_py35()
instead offspath()
here, since in Python 3.6+ you may pass Path-like object toos
utils directly.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.
Changed, thanks.