mirror of
https://github.com/Stone-Red-Code/dvc.git
synced 2026-11-02 07:18:25 +01:00
test: fix unicode test_ignore issue under Windows Py2
This commit is contained in:
@@ -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")
|
||||
|
||||
@@ -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"}
|
||||
|
||||
Reference in New Issue
Block a user