mirror of
https://github.com/Stone-Red-Code/dvc.git
synced 2026-11-02 07:18:25 +01:00
dvcignore: use fs.path instead of os.path
This commit is contained in:
@@ -115,7 +115,8 @@ def test_ignore_collecting_dvcignores(tmp_dir, dvc, dname):
|
||||
os.fspath(tmp_dir),
|
||||
_to_pattern_info_list([os.path.basename(dname)]),
|
||||
top_ignore_path,
|
||||
)
|
||||
),
|
||||
os.sep,
|
||||
)
|
||||
== dvcignore._get_trie_pattern(top_ignore_path)
|
||||
== dvcignore._get_trie_pattern(sub_dir_path)
|
||||
@@ -140,7 +141,7 @@ def test_ignore_on_branch(tmp_dir, scm, dvc):
|
||||
}
|
||||
|
||||
dvc.fs = GitFileSystem(scm=scm, rev="branch")
|
||||
assert dvc.dvcignore.is_ignored_file(tmp_dir / "foo")
|
||||
assert dvc.dvcignore.is_ignored_file((tmp_dir / "foo").fs_path)
|
||||
|
||||
|
||||
def test_match_nested(tmp_dir, dvc):
|
||||
@@ -372,15 +373,15 @@ def test_pattern_trie_fs(tmp_dir, dvc):
|
||||
os.fspath(tmp_dir / "other"),
|
||||
)
|
||||
|
||||
assert DvcIgnorePatterns(*base_pattern) == ignore_pattern_top
|
||||
assert DvcIgnorePatterns(*other_pattern) == ignore_pattern_other
|
||||
assert DvcIgnorePatterns(*base_pattern, os.sep) == ignore_pattern_top
|
||||
assert DvcIgnorePatterns(*other_pattern, os.sep) == ignore_pattern_other
|
||||
assert (
|
||||
DvcIgnorePatterns(*first_pattern)
|
||||
DvcIgnorePatterns(*first_pattern, os.sep)
|
||||
== ignore_pattern_first
|
||||
== ignore_pattern_middle
|
||||
)
|
||||
assert (
|
||||
DvcIgnorePatterns(*second_pattern)
|
||||
DvcIgnorePatterns(*second_pattern, os.sep)
|
||||
== ignore_pattern_second
|
||||
== ignore_pattern_bottom
|
||||
)
|
||||
|
||||
@@ -7,7 +7,10 @@ from dvc.ignore import DvcIgnorePatterns
|
||||
|
||||
|
||||
def mock_dvcignore(dvcignore_path, patterns):
|
||||
from dvc.fs.local import localfs
|
||||
|
||||
fs = MagicMock()
|
||||
fs.path = localfs.path
|
||||
with patch.object(fs, "open", mock_open(read_data="\n".join(patterns))):
|
||||
ignore_patterns = DvcIgnorePatterns.from_file(
|
||||
dvcignore_path, fs, "mocked"
|
||||
@@ -195,7 +198,7 @@ def test_match_ignore_from_file(
|
||||
@pytest.mark.parametrize("omit_dir", [".git", ".hg", ".dvc"])
|
||||
def test_should_ignore_dir(omit_dir, sub_dir):
|
||||
root = os.path.join(os.path.sep, "walk", "dir", "root")
|
||||
ignore = DvcIgnorePatterns([".git/", ".hg/", ".dvc/"], root)
|
||||
ignore = DvcIgnorePatterns([".git/", ".hg/", ".dvc/"], root, os.sep)
|
||||
|
||||
dirs = [omit_dir, "dir1", "dir2"]
|
||||
files = [omit_dir, "file1", "file2"]
|
||||
|
||||
Reference in New Issue
Block a user