test: fix unicode test_ignore issue under Windows Py2

This commit is contained in:
Alexander Schepanovski
2019-12-07 17:17:18 +01:00
parent 79902988fc
commit 6c12a2e555
2 changed files with 8 additions and 3 deletions
+2 -2
View File
@@ -6,7 +6,7 @@ import pytest
from funcy.py3 import lmap, retry
from dvc.utils import makedirs
from dvc.utils.compat import basestring, is_py2, pathlib, fspath, fspath_py35
from dvc.utils.compat import basestring, pathlib, fspath, fspath_py35, bytes
__all__ = ["tmp_dir", "scm", "dvc", "repo_template", "run_copy", "erepo_dir"]
@@ -61,7 +61,7 @@ class TmpDir(pathlib.Path):
self._gen(contents, prefix=path)
else:
makedirs(path.parent, exist_ok=True)
if is_py2 and isinstance(contents, str):
if isinstance(contents, bytes):
path.write_bytes(contents)
else:
path.write_text(contents, encoding="utf-8")
+6 -1
View File
@@ -25,7 +25,12 @@ def test_ignore(tmp_dir, dvc, monkeypatch):
def test_ignore_unicode(tmp_dir, dvc):
tmp_dir.gen({"dir": {"тест": "проверка", "other": "text"}})
tmp_dir.gen({"dir": {"other": "text"}})
# Path() doesn't handle unicode paths in Windows/Python 2
# I don't know to debug it further, waiting till Python 2 EOL
with open("dir/тест", "wb") as fd:
fd.write("проверка".encode("utf-8"))
tmp_dir.gen(DvcIgnore.DVCIGNORE_FILE, "dir/тест")
assert _files_set("dir", dvc.dvcignore) == {"dir/other"}