diff options
author | Elena ``of Valhalla'' Grandi <valhalla@trueelena.org> | 2021-03-19 09:34:22 +0100 |
---|---|---|
committer | Elena ``of Valhalla'' Grandi <valhalla@trueelena.org> | 2021-03-19 09:34:22 +0100 |
commit | 897bd5e601f9a602b2e0aef592780c63d3730048 (patch) | |
tree | 9e3f9b988879ecb461d9a510dfc6cf2bbb95b84c /tests | |
parent | 2def416dba68521b9387fc98b20ec99cea6a2efa (diff) |
Fix converting multiline and long strings to yaml
Diffstat (limited to 'tests')
-rw-r--r-- | tests/test_templating.py | 18 |
1 files changed, 17 insertions, 1 deletions
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() |