From 897bd5e601f9a602b2e0aef592780c63d3730048 Mon Sep 17 00:00:00 2001 From: Elena ``of Valhalla'' Grandi Date: Fri, 19 Mar 2021 09:34:22 +0100 Subject: Fix converting multiline and long strings to yaml --- tests/test_templating.py | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) (limited to 'tests') diff --git a/tests/test_templating.py b/tests/test_templating.py index 33889ae..aadcf66 100644 --- a/tests/test_templating.py +++ b/tests/test_templating.py @@ -28,7 +28,16 @@ class testFilters(unittest.TestCase): """ res = templating.to_yaml(s) self.assertIsInstance(res, str) - self.assertIn('"', res) + self.assertTrue(res.startswith('|')) + self.assertIn('\n', res) + + s = """ + short + multiline + """ + res = templating.to_yaml(s) + self.assertIsInstance(res, str) + self.assertTrue(res.startswith('|')) self.assertIn('\n', res) res = templating.to_yaml(10) @@ -37,6 +46,13 @@ class testFilters(unittest.TestCase): res = templating.to_yaml(decimal.Decimal('10.1')) self.assertEqual(res, "'10.1'") + s = "A very long line, but one that has no new lines " \ + + "even if it is definitely longer than a standard " \ + + "80 columns line" + res = templating.to_yaml(s) + self.assertTrue(res.startswith("|\n")) + self.assertNotIn('\n', res.lstrip("|\n")) + if __name__ == '__main__': unittest.main() -- cgit v1.2.3