Files
dvc/tests/unit/utils/serialize/test_yaml.py
T
Ruslan Kuprieiev 3878c50ea8 yaml: wrap ruamel's DuplicateKeyError (#4668)
* yaml: wrap ruamel's DuplicateKeyError

Unfortunately ruamel's exception doesn't contain much info that we could
reuse, so we can only reasonably extract the exc.problem and have
something like:

```
ERROR: failed to obtain data status - unable to read: 'dvc.yaml', found
duplicate key "metrics" with value "[]" (original value: "[]")
```

Fixes #4664

* status: remove unneeded error prefix
2020-10-05 23:02:59 +03:00

15 lines
293 B
Python

import pytest
from dvc.utils.serialize._yaml import YAMLError, parse_yaml
def test_parse_yaml_duplicate_key_error():
text = """\
mykey:
- foo
mykey:
- bar
"""
with pytest.raises(YAMLError, match='found duplicate key "mykey"'):
parse_yaml(text, "mypath")