Skip to content

Commit 6c12a2e

Browse files
committed
test: fix unicode test_ignore issue under Windows Py2
1 parent 7990298 commit 6c12a2e

File tree

2 files changed

+8
-3
lines changed

2 files changed

+8
-3
lines changed

tests/dir_helpers.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
from funcy.py3 import lmap, retry
77

88
from dvc.utils import makedirs
9-
from dvc.utils.compat import basestring, is_py2, pathlib, fspath, fspath_py35
9+
from dvc.utils.compat import basestring, pathlib, fspath, fspath_py35, bytes
1010

1111

1212
__all__ = ["tmp_dir", "scm", "dvc", "repo_template", "run_copy", "erepo_dir"]
@@ -61,7 +61,7 @@ def _gen(self, struct, prefix=None):
6161
self._gen(contents, prefix=path)
6262
else:
6363
makedirs(path.parent, exist_ok=True)
64-
if is_py2 and isinstance(contents, str):
64+
if isinstance(contents, bytes):
6565
path.write_bytes(contents)
6666
else:
6767
path.write_text(contents, encoding="utf-8")

tests/func/test_ignore.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,12 @@ def test_ignore(tmp_dir, dvc, monkeypatch):
2525

2626

2727
def test_ignore_unicode(tmp_dir, dvc):
28-
tmp_dir.gen({"dir": {"тест": "проверка", "other": "text"}})
28+
tmp_dir.gen({"dir": {"other": "text"}})
29+
# Path() doesn't handle unicode paths in Windows/Python 2
30+
# I don't know to debug it further, waiting till Python 2 EOL
31+
with open("dir/тест", "wb") as fd:
32+
fd.write("проверка".encode("utf-8"))
33+
2934
tmp_dir.gen(DvcIgnore.DVCIGNORE_FILE, "dir/тест")
3035

3136
assert _files_set("dir", dvc.dvcignore) == {"dir/other"}

0 commit comments

Comments
 (0)