Skip to content

Commit

Permalink
YAML: Add test for changing type of an string
Browse files Browse the repository at this point in the history
When some item was a string previously and was changed to dict or list,
it should be gracefully handled.

Fixes WeblateOrg/weblate#4316
  • Loading branch information
nijel committed Sep 9, 2020
1 parent 92f1c9a commit a94c13e
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions translate/storage/test_yaml.py
Expand Up @@ -417,3 +417,20 @@ def test_anchors(self):
store.parse(data)
assert len(store.units) == 5
assert bytes(store).decode('ascii') == data

def test_type_change(self):
original = '''en:
days_on: '["Sunday", "Monday"]'
'''
changed = '''en:
days_on:
- Sunday
- Monday
'''
store = self.StoreClass()
store.parse(original)
update = self.StoreClass()
update.parse(changed)
for unit in update.units:
store.addunit(unit)
assert bytes(store).decode('ascii') == changed

0 comments on commit a94c13e

Please sign in to comment.