mirror of
https://github.com/Stone-Red-Code/dvc.git
synced 2026-11-02 07:18:25 +01:00
This PR is just a showcase to see how we like it. I've converted a few
tests to it, but there will be much more to come.
```
assert (tmp_dir / "file") == "contents"
assert (tmp_dir / "dir").read_text() == {"subdir": {"file": "hello"}}
```
This approach is nicer because it allows us to use a declaratory
asserts instead of relying on fs files. The problem becomes much more
apparent once you get into remote workspaces, where we `trees_equal`
doesn't work.
24 lines
416 B
Python
24 lines
416 B
Python
import os
|
|
from contextlib import contextmanager
|
|
|
|
from dvc.scm import Git
|
|
|
|
|
|
def get_gitignore_content():
|
|
with open(Git.GITIGNORE) as gitignore:
|
|
return gitignore.read().splitlines()
|
|
|
|
|
|
@contextmanager
|
|
def cd(newdir):
|
|
prevdir = os.getcwd()
|
|
os.chdir(os.path.expanduser(newdir))
|
|
try:
|
|
yield
|
|
finally:
|
|
os.chdir(prevdir)
|
|
|
|
|
|
def to_posixpath(path):
|
|
return path.replace("\\", "/")
|