Skip to content

Commit

Permalink
Exclude a test when using the macOS system libraries because it fails…
Browse files Browse the repository at this point in the history
… with libxml2 2.9.4.
  • Loading branch information
scoder committed Dec 10, 2021
1 parent cd4bec9 commit d85c6de
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 3 deletions.
7 changes: 7 additions & 0 deletions src/lxml/tests/common_imports.py
Expand Up @@ -69,6 +69,13 @@ def dummy_test_method(self):
if expected_version > current_version:
setattr(test_class, name, dummy_test_method)


def needs_libxml(*version):
return unittest.skipIf(
etree.LIBXML_VERSION >= version,
"needs libxml2 >= %s.%s.%s" % (version + (0, 0, 0))[:3])


import doctest

try:
Expand Down
5 changes: 3 additions & 2 deletions src/lxml/tests/test_htmlparser.py
Expand Up @@ -10,7 +10,7 @@
import tempfile, os, os.path, sys

from .common_imports import etree, html, BytesIO, fileInTestDir, _bytes, _str
from .common_imports import SillyFileLike, HelperTestCase, write_to_file
from .common_imports import SillyFileLike, HelperTestCase, write_to_file, needs_libxml

try:
unicode
Expand Down Expand Up @@ -53,7 +53,8 @@ def test_module_HTML_unicode(self):
self.assertEqual(element.findtext('.//h1'),
_bytes("page á title").decode('utf8'))

def test_wide_unicode_xml(self):
@needs_libxml(2, 9, 5) # not sure, at least 2.9.4 fails
def test_wide_unicode_html(self):
if sys.maxunicode < 1114111:
return # skip test
element = self.etree.HTML(_bytes(
Expand Down
3 changes: 2 additions & 1 deletion src/lxml/tests/test_unicode.py
Expand Up @@ -4,7 +4,7 @@
import unittest
import sys

from .common_imports import StringIO, etree, HelperTestCase, _str, _bytes, _chr
from .common_imports import StringIO, etree, HelperTestCase, _str, _bytes, _chr, needs_libxml

try:
unicode
Expand Down Expand Up @@ -34,6 +34,7 @@ def test_unicode_xml(self):
tree = etree.XML('<p>%s</p>' % uni)
self.assertEqual(uni, tree.text)

@needs_libxml(2, 9, 5) # not sure, at least 2.9.4 fails
def test_wide_unicode_xml(self):
if sys.maxunicode < 1114111:
return # skip test
Expand Down

0 comments on commit d85c6de

Please sign in to comment.