Code Duplication    Length = 18-20 lines in 2 locations

tests/test_xml.py 2 locations

@@ 98-117 (lines=20) @@
95
            b'<text>' + new_elem.text.encode('utf-8') + b'</text>', elem_as_str
96
        )
97
98
    def test_escape_xml_printable_char(self):
99
        text = 'Latin Capital Letter A With Circumflex \xc2 is printable.'
100
        res = escape_ctrl_chars(text)
101
        self.assertEqual(
102
            res, 'Latin Capital Letter A With Circumflex  is printable.'
103
        )
104
105
        # Create the element
106
        elem = Element('text')
107
        elem.text = res
108
        self.assertEqual(
109
            tostring(elem),
110
            b'<text>Latin Capital Letter A With Circumflex &#194; is printable.</text>',
111
        )
112
113
        # The string format of the element does not break the xml
114
        elem_as_str = tostring(elem, encoding='utf-8')
115
        new_elem = fromstring(elem_as_str)
116
        self.assertEqual(
117
            b'<text>' + new_elem.text.encode('utf-8') + b'</text>', elem_as_str
118
        )
119
@@ 78-95 (lines=18) @@
75
76
        self.assertEqual(text, res)
77
78
    def test_escape_xml_invalid_char(self):
79
        text = 'End of transmission is not printable \x04.'
80
        res = escape_ctrl_chars(text)
81
        self.assertEqual(res, 'End of transmission is not printable \\x0004.')
82
83
        # Create element
84
        elem = Element('text')
85
        elem.text = res
86
        self.assertEqual(
87
            tostring(elem),
88
            b'<text>End of transmission is not printable \\x0004.</text>',
89
        )
90
91
        # The string format of the element does not break the xml.
92
        elem_as_str = tostring(elem, encoding='utf-8')
93
        new_elem = fromstring(elem_as_str)
94
        self.assertEqual(
95
            b'<text>' + new_elem.text.encode('utf-8') + b'</text>', elem_as_str
96
        )
97
98
    def test_escape_xml_printable_char(self):