test: escape_xml

This commit is contained in:
QuentinN42
2022-02-10 12:17:38 +01:00
parent dab7a8089b
commit b1ce2f290b
3 changed files with 3944 additions and 1 deletions

24
tests/test_format.py Normal file
View File

@@ -0,0 +1,24 @@
# -*- coding: utf-8 -*-
import unittest
import string
from yamllint.format import escape_xml, severity_from_level
class TextToXMLTestCase(unittest.TestCase):
specials = {
'&': '&',
'<': '&lt;',
'>': '&gt;',
'"': '&quot;',
"'": '&apos;'
}
def test_letters_chars(self):
txt = string.ascii_letters
self.assertEqual(escape_xml(txt), txt)
def test_specials_chars(self):
for inp, out in self.specials.items():
self.assertEqual(escape_xml(inp), out)