-
Notifications
You must be signed in to change notification settings - Fork 1
/
test.py
48 lines (40 loc) · 972 Bytes
/
test.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
39
40
41
42
43
44
45
46
47
48
from collections import OrderedDict
import pytest
import simple_yaml as yaml
def test_order():
yamltext = """
a:
x: 1
y: 2
z: 3
b: 0
c: 0
d: 0
"""
for i in range(100):
data = yaml.load(yamltext)
assert isinstance(data, OrderedDict)
assert isinstance(data['a'], OrderedDict)
assert list(data['a'].items()) == [('x', 1), ('y', 2), ('z', 3)]
del data['a']
assert list(data.items()) == [('b', 0), ('c', 0), ('d', 0)]
@pytest.mark.parametrize("text", [
'@user', '&user', '*user',
"""
friends:
- @user
""",
'userid: @userid',
'&optional&unique'
])
def test_special_yaml_char(text):
yaml.load(text)
def test_anchors_aliases():
text = """
left hand: &A
name: The Bastard Sword of Eowyn
weight: 30
right hand: *A
"""
with pytest.raises(yaml.YAMLError):
yaml.load(text)