This test demonstrates the expected functionality:
|
def with_comments_on_list_items(expect): |
|
sample = SampleWithListOfDataclasses() |
|
|
|
write( |
|
'tmp/sample.yml', |
|
""" |
|
# Header |
|
|
|
items: # Subheader |
|
|
|
# Section |
|
|
|
- name: a # Item |
|
score: 1 |
|
|
|
# Section |
|
|
|
- name: b # Item |
|
score: 2 |
|
""", |
|
) |
|
|
|
sample.datafile.load() |
|
sample.items[1].name = 'c' |
|
sample.datafile.save() |
|
|
|
expect(read('tmp/sample.yml')) == dedent( |
|
""" |
|
# Header |
|
|
|
items: # Subheader |
|
|
|
# Section |
|
|
|
- name: a # Item |
|
score: 1 |
|
|
|
# Section |
|
|
|
- name: c # Item |
|
score: 2 |
|
""" |
|
) |
This appears to be an issue with the YAML library: https://sourceforge.net/p/ruamel-yaml/tickets/318/
This test demonstrates the expected functionality:
datafiles/tests/test_saving.py
Lines 408 to 450 in a51507b
This appears to be an issue with the YAML library: https://sourceforge.net/p/ruamel-yaml/tickets/318/