--- a/src/lxml/tests/test_unicode.py +++ b/src/lxml/tests/test_unicode.py @@ -167,7 +167,11 @@ def test_illegal_utf8_recover(self): data = _bytes('\x80\x80\x80', encoding='iso8859-1') parser = etree.XMLParser(recover=True) - self.assertRaises(etree.XMLSyntaxError, etree.fromstring, data, parser) + if etree.LIBXML_VERSION >= (2, 12, 0): + tree = etree.fromstring(data, parser) + self.assertEqual('\ufffd\ufffd\ufffd', tree.text) + else: + self.assertRaises(etree.XMLSyntaxError, etree.fromstring, data, parser) def _test_encoding(self, encoding, xml_encoding_name=None): foo = """\n""" % (