test: escape_xml
This commit is contained in:
3919
coverage.xml
Normal file
3919
coverage.xml
Normal file
File diff suppressed because it is too large
Load Diff
24
tests/test_format.py
Normal file
24
tests/test_format.py
Normal 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 = {
|
||||
'&': '&',
|
||||
'<': '<',
|
||||
'>': '>',
|
||||
'"': '"',
|
||||
"'": '''
|
||||
}
|
||||
|
||||
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)
|
||||
@@ -37,7 +37,7 @@ def escape_xml(text):
|
||||
text = text.replace('<', '<')
|
||||
text = text.replace('>', '>')
|
||||
text = text.replace('"', '"')
|
||||
text = text.replace('"', ''')
|
||||
text = text.replace("'", ''')
|
||||
return text
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user