diff options
author | Richard Maw <richard.maw@codethink.co.uk> | 2014-07-30 12:30:30 +0000 |
---|---|---|
committer | Richard Maw <richard.maw@codethink.co.uk> | 2014-07-30 12:43:43 +0000 |
commit | 391d8cec9ae74a5f1d3b4101f4542a81f63d9860 (patch) | |
tree | be34cff00a09e3baba0e0045ebaa7004faa7781d /morphlib/morphloader_tests.py | |
parent | f860d3e7b0e14b01b31d4f3d63a8c37572cd9fdc (diff) | |
download | morph-391d8cec9ae74a5f1d3b4101f4542a81f63d9860.tar.gz |
Dump multi-line strings in yaml documents in '|' formbaserock/richardmaw/bugfix/yaml-multi-line-dump
This prevents the description fields of morphologies being mangled.
This does not preserve the original formatting, so much as happen to
dump it in the same way we wrote it, but given we chose that form
because we think it looks the nicest, that's not a problem.
Diffstat (limited to 'morphlib/morphloader_tests.py')
-rw-r--r-- | morphlib/morphloader_tests.py | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/morphlib/morphloader_tests.py b/morphlib/morphloader_tests.py index 82663298..f4d2f9b6 100644 --- a/morphlib/morphloader_tests.py +++ b/morphlib/morphloader_tests.py @@ -912,3 +912,33 @@ build-system: dummy # deployment keys field order self.assertLess(s.find('type'), s.find('location')) self.assertLess(s.find('location'), s.find('HOSTNAME')) + + def test_multi_line_round_trip(self): + s = ('name: foo\n' + 'kind: bar\n' + 'description: |\n' + ' 1 2 3\n' + ' 4 5 6\n' + ' 7 8 9\n') + m = self.loader.parse_morphology_text(s, 'string') + self.assertEqual(s, self.loader.save_to_string(m)) + + def test_smoketest_multi_line_unicode(self): + m = morphlib.morph3.Morphology( + name=u'foo', + description=u'1 2 3\n4 5 6\n7 8 9\n', + ) + s = self.loader.save_to_string(m) + + def test_smoketest_multi_line_unicode_encoded(self): + m = morphlib.morph3.Morphology( + name=u'foo \u263A'.encode('utf-8'), + description=u'1 \u263A\n2 \u263A\n3 \u263A\n'.encode('utf-8'), + ) + s = self.loader.save_to_string(m) + + def test_smoketest_binary_garbage(self): + m = morphlib.morph3.Morphology( + description='\x92', + ) + s = self.loader.save_to_string(m) |