mirror of
https://github.com/Stone-Red-Code/dvc.git
synced 2026-11-04 23:09:44 +01:00
* test: remove never used copy of load_stage_file() * dvc: save comments and custom formatting in stage files * Add a couple of TODOs * test: test repro doesn't clear comments and formatting in .dvc As part of this I started writing pytest-like tests and added commonly used fixtures. * test: simplify and prettify dvc formatting retained test Also test that line comments after md5 fields are retained. * test: fix tests * dvc: fix stage and metrics opens not closed * dvc: always use utf-8 in stage files It used to encode in system default encoding. Not sure if PyYAML was handling this silently or we were just lucky all the way. * test: unit test apply_diff() * test: remove TODOs and ASK * dvc: polish dvc-formatting PR * dvc: move stage load/dump utils to a new stage utils file * dvc: clean up apply_diff() * test: test stage md5 ignores comments * test: remove pytests starting marker
32 lines
613 B
Python
32 lines
613 B
Python
import os
|
|
|
|
from dvc.scm import Git
|
|
from mock import MagicMock
|
|
from contextlib import contextmanager
|
|
|
|
|
|
def spy(method_to_decorate):
|
|
mock = MagicMock()
|
|
|
|
def wrapper(self, *args, **kwargs):
|
|
mock(*args, **kwargs)
|
|
return method_to_decorate(self, *args, **kwargs)
|
|
|
|
wrapper.mock = mock
|
|
return wrapper
|
|
|
|
|
|
def get_gitignore_content():
|
|
with open(Git.GITIGNORE, "r") 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)
|