mirror of
https://github.com/Stone-Red-Code/dvc.git
synced 2026-11-19 15:28:28 +01:00
dvc: retain formatting and comments in .dvc files (#1885)
* 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
This commit is contained in:
committed by
Ruslan Kuprieiev
parent
b057c814ea
commit
0c867399bb
@@ -1,5 +1,4 @@
|
||||
import yaml
|
||||
from dvc.utils import load_stage_file
|
||||
from dvc.utils.stage import load_stage_file, dump_stage_file
|
||||
|
||||
from tests.basic_env import TestDvc
|
||||
from dvc.stage import StageCommitError
|
||||
@@ -78,10 +77,8 @@ class TestCommitChangedMd5(TestDvc):
|
||||
stage = stages[0]
|
||||
|
||||
st = load_stage_file(stage.path)
|
||||
|
||||
st["md5"] = "1111111111"
|
||||
with open(stage.path, "w") as fobj:
|
||||
yaml.safe_dump(st, fobj, default_flow_style=False)
|
||||
dump_stage_file(stage.path, st)
|
||||
|
||||
with self.assertRaises(StageCommitError):
|
||||
self.dvc.commit(stage.path)
|
||||
|
||||
Reference in New Issue
Block a user