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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
|
# coding: utf-8
from roundtrip import YAML
import pytest # NOQA
def test_example_2_1():
yaml = YAML()
yaml.round_trip("""
- Mark McGwire
- Sammy Sosa
- Ken Griffey
""")
@pytest.mark.xfail(strict=True)
def test_example_2_2():
yaml = YAML()
yaml.mapping_value_align = True
yaml.round_trip("""
hr: 65 # Home runs
avg: 0.278 # Batting average
rbi: 147 # Runs Batted In
""")
def test_example_2_3():
yaml = YAML()
yaml.indent(sequence=4, offset=2)
yaml.round_trip("""
american:
- Boston Red Sox
- Detroit Tigers
- New York Yankees
national:
- New York Mets
- Chicago Cubs
- Atlanta Braves
""")
@pytest.mark.xfail(strict=True)
def test_example_2_4():
yaml = YAML()
yaml.mapping_value_align = True
yaml.round_trip("""
-
name: Mark McGwire
hr: 65
avg: 0.278
-
name: Sammy Sosa
hr: 63
avg: 0.288
""")
@pytest.mark.xfail(strict=True)
def test_example_2_5():
yaml = YAML()
yaml.flow_sequence_element_align = True
yaml.round_trip("""
- [name , hr, avg ]
- [Mark McGwire, 65, 0.278]
- [Sammy Sosa , 63, 0.288]
""")
@pytest.mark.xfail(strict=True)
def test_example_2_6():
yaml = YAML()
# yaml.flow_mapping_final_comma = False
yaml.flow_mapping_one_element_per_line = True
yaml.round_trip("""
Mark McGwire: {hr: 65, avg: 0.278}
Sammy Sosa: {
hr: 63,
avg: 0.288
}
""")
@pytest.mark.xfail(strict=True)
def test_example_2_7():
yaml = YAML()
yaml.round_trip_all("""
# Ranking of 1998 home runs
---
- Mark McGwire
- Sammy Sosa
- Ken Griffey
# Team ranking
---
- Chicago Cubs
- St Louis Cardinals
""")
def test_example_2_8():
yaml = YAML()
yaml.explicit_start = True
yaml.explicit_end = True
yaml.round_trip_all("""
---
time: 20:03:20
player: Sammy Sosa
action: strike (miss)
...
---
time: 20:03:47
player: Sammy Sosa
action: grand slam
...
""")
def test_example_2_9():
yaml = YAML()
yaml.explicit_start = True
yaml.indent(sequence=4, offset=2)
yaml.round_trip("""
---
hr: # 1998 hr ranking
- Mark McGwire
- Sammy Sosa
rbi:
# 1998 rbi ranking
- Sammy Sosa
- Ken Griffey
""")
@pytest.mark.xfail(strict=True)
def test_example_2_10():
yaml = YAML()
yaml.explicit_start = True
yaml.indent(sequence=4, offset=2)
yaml.round_trip("""
---
hr:
- Mark McGwire
# Following node labeled SS
- &SS Sammy Sosa
rbi:
- *SS # Subsequent occurrence
- Ken Griffey
""")
@pytest.mark.xfail(strict=True)
def test_example_2_11():
yaml = YAML()
yaml.round_trip("""
? - Detroit Tigers
- Chicago cubs
:
- 2001-07-23
? [ New York Yankees,
Atlanta Braves ]
: [ 2001-07-02, 2001-08-12,
2001-08-14 ]
""")
@pytest.mark.xfail(strict=True)
def test_example_2_12():
yaml = YAML()
yaml.explicit_start = True
yaml.round_trip("""
---
# Products purchased
- item : Super Hoop
quantity: 1
- item : Basketball
quantity: 4
- item : Big Shoes
quantity: 1
""")
@pytest.mark.xfail(strict=True)
def test_example_2_13():
yaml = YAML()
yaml.round_trip(r"""
# ASCII Art
--- |
\//||\/||
// || ||__
""")
@pytest.mark.xfail(strict=True)
def test_example_2_14():
yaml = YAML()
yaml.explicit_start = True
yaml.indent(root_scalar=2) # needs to be added
yaml.round_trip("""
--- >
Mark McGwire's
year was crippled
by a knee injury.
""")
@pytest.mark.xfail(strict=True)
def test_example_2_15():
yaml = YAML()
yaml.round_trip("""
>
Sammy Sosa completed another
fine season with great stats.
63 Home Runs
0.288 Batting Average
What a year!
""")
def test_example_2_16():
yaml = YAML()
yaml.round_trip("""
name: Mark McGwire
accomplishment: >
Mark set a major league
home run record in 1998.
stats: |
65 Home Runs
0.278 Batting Average
""")
@pytest.mark.xfail(
strict=True, reason='cannot YAML dump escape sequences (\n) as hex and normal'
)
def test_example_2_17():
yaml = YAML()
yaml.allow_unicode = False
yaml.preserve_quotes = True
yaml.round_trip(r"""
unicode: "Sosa did fine.\u263A"
control: "\b1998\t1999\t2000\n"
hex esc: "\x0d\x0a is \r\n"
single: '"Howdy!" he cried.'
quoted: ' # Not a ''comment''.'
tie-fighter: '|\-*-/|'
""")
@pytest.mark.xfail(strict=True, reason='non-literal/folding multiline scalars not supported')
def test_example_2_18():
yaml = YAML()
yaml.round_trip("""
plain:
This unquoted scalar
spans many lines.
quoted: "So does this
quoted scalar.\n"
""")
@pytest.mark.xfail(strict=True, reason='leading + on decimal dropped')
def test_example_2_19():
yaml = YAML()
yaml.round_trip("""
canonical: 12345
decimal: +12345
octal: 0o14
hexadecimal: 0xC
""")
@pytest.mark.xfail(strict=True, reason='case of NaN not preserved')
def test_example_2_20():
yaml = YAML()
yaml.round_trip("""
canonical: 1.23015e+3
exponential: 12.3015e+02
fixed: 1230.15
negative infinity: -.inf
not a number: .NaN
""")
def Xtest_example_2_X():
yaml = YAML()
yaml.round_trip("""
""")
|