-
Notifications
You must be signed in to change notification settings - Fork 0
/
disabled_yaml.py
38 lines (32 loc) · 887 Bytes
/
disabled_yaml.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
"""
Test cases for toy JAyamlP
You can filter to just one test case by running:
pytest -k '2-1-'
"""
import glob
import json
import lib
import pytest
@pytest.mark.parametrize("tml_path", [
pytest.param(path,
id=path.replace('yaml-test-suite/test/name/spec-example-',
'').replace('.tml', ''))
for path in glob.glob("yaml-test-suite/test/name/spec-example-*.tml")
])
def test_(tml_path):
parts, curr = {}, 'head'
with open(tml_path) as f:
for line in f:
if line.startswith('--- '):
curr = line[4:].strip()
else:
parts.setdefault(curr, []).append(line)
try:
in_yaml = ''.join(parts['in-yaml'])
in_json = ''.join(parts['in-json'])
except e:
print(e)
return
expected = json.loads(in_json)
actual = lib.yaml(in_yaml)
assert expected == actual, in_yaml