diff options
author | Richard Maw <richard.maw@codethink.co.uk> | 2014-02-17 15:20:44 +0000 |
---|---|---|
committer | Richard Maw <richard.maw@codethink.co.uk> | 2014-02-17 15:50:00 +0000 |
commit | be8ffd80be76c12a268b7199e5e05772f18cd30a (patch) | |
tree | 24be39bd8c614e9c96d0ddcb5cc2d78dc05325f5 /morphlib/morph2_tests.py | |
parent | d3e386a632cd9a45c74cfcdeb44e1310616c52d5 (diff) | |
download | morph-be8ffd80be76c12a268b7199e5e05772f18cd30a.tar.gz |
Legacy morph code: Also dump in specified order
This rips out any remaining order-preserving code and instead uses the
yaml dumper from morphloader.
Diffstat (limited to 'morphlib/morph2_tests.py')
-rw-r--r-- | morphlib/morph2_tests.py | 23 |
1 files changed, 6 insertions, 17 deletions
diff --git a/morphlib/morph2_tests.py b/morphlib/morph2_tests.py index ba90313f..d02aab1c 100644 --- a/morphlib/morph2_tests.py +++ b/morphlib/morph2_tests.py @@ -19,6 +19,8 @@ import json import StringIO import unittest +import yaml + import morphlib from morphlib.morph2 import Morphology @@ -251,19 +253,6 @@ class MorphologyTests(unittest.TestCase): ] }''' - def test_writing_preserves_chunk_order(self): - text_lines = self.stratum_text.splitlines() - text_lines[6] = ' "ref": "new-ref",' - - # Change one of the fields - morphology = Morphology(self.stratum_text) - morphology['chunks'][0]['ref'] = 'new-ref' - - output = StringIO.StringIO() - morphology.update_text(self.stratum_text, output) - output_lines = output.getvalue().splitlines() - self.assertEqual(text_lines, output_lines) - def test_writing_handles_added_chunks(self): text_lines = self.stratum_text.splitlines() text_lines = text_lines[0:16] + text_lines[8:17] + text_lines[17:] @@ -276,8 +265,8 @@ class MorphologyTests(unittest.TestCase): output = StringIO.StringIO() morphology.update_text(self.stratum_text, output) - output_lines = output.getvalue().splitlines() - self.assertEqual(text_lines, output_lines) + d = yaml.load(output.getvalue()) + self.assertEqual(d['chunks'][2]['name'], 'baz') def test_writing_handles_deleted_chunks(self): text_lines = self.stratum_text.splitlines() @@ -289,8 +278,8 @@ class MorphologyTests(unittest.TestCase): output = StringIO.StringIO() morphology.update_text(self.stratum_text, output) - output_lines = output.getvalue().splitlines() - self.assertEqual(text_lines, output_lines) + d = yaml.load(output.getvalue()) + self.assertEqual(len(d['chunks']), 1) system_text = '''{ "kind": "system", |