You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
yamllint/tests/test_format.py

41 lines
903 B
Python

3 years ago
# -*- 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)
class CodeClimateSeverityTestCase(unittest.TestCase):
expected = {
None: "info",
'warning': "minor",
'error': "major",
0: "info",
1: "minor",
2: "major",
}
def test_specials_chars(self):
for inp, out in self.expected.items():
self.assertEqual(severity_from_level(inp), out)