summaryrefslogtreecommitdiff
path: root/bs4/tests/test_lxml.py
diff options
context:
space:
mode:
Diffstat (limited to 'bs4/tests/test_lxml.py')
-rw-r--r--bs4/tests/test_lxml.py30
1 files changed, 15 insertions, 15 deletions
diff --git a/bs4/tests/test_lxml.py b/bs4/tests/test_lxml.py
index e88515c..c7bf45d 100644
--- a/bs4/tests/test_lxml.py
+++ b/bs4/tests/test_lxml.py
@@ -1,16 +1,10 @@
"""Tests to ensure that the lxml tree builder generates good trees."""
import pickle
+import pytest
import re
import warnings
-
-try:
- import lxml.etree
- LXML_PRESENT = True
- LXML_VERSION = lxml.etree.LXML_VERSION
-except ImportError as e:
- LXML_PRESENT = False
- LXML_VERSION = (0,)
+from . import LXML_PRESENT, LXML_VERSION
if LXML_PRESENT:
from bs4.builder import LXMLTreeBuilder, LXMLTreeBuilderForXML
@@ -23,13 +17,14 @@ from bs4.element import Comment, Doctype, SoupStrainer
from . import (
HTMLTreeBuilderSmokeTest,
XMLTreeBuilderSmokeTest,
+ SOUP_SIEVE_PRESENT,
SoupTest,
- skipIf,
)
-@skipIf(
+@pytest.mark.skipif(
not LXML_PRESENT,
- "lxml seems not to be present, not testing its tree builder.")
+ reason="lxml seems not to be present, not testing its tree builder."
+)
class TestLXMLTreeBuilder(SoupTest, HTMLTreeBuilderSmokeTest):
"""See ``HTMLTreeBuilderSmokeTest``."""
@@ -54,9 +49,10 @@ class TestLXMLTreeBuilder(SoupTest, HTMLTreeBuilderSmokeTest):
# In lxml < 2.3.5, an empty doctype causes a segfault. Skip this
# test if an old version of lxml is installed.
- @skipIf(
+ @pytest.mark.skipif(
not LXML_PRESENT or LXML_VERSION < (2,3,5,0),
- "Skipping doctype test for old version of lxml to avoid segfault.")
+ reason="Skipping doctype test for old version of lxml to avoid segfault."
+ )
def test_empty_doctype(self):
soup = self.soup("<!DOCTYPE>")
doctype = soup.contents[0]
@@ -87,9 +83,10 @@ class TestLXMLTreeBuilder(SoupTest, HTMLTreeBuilderSmokeTest):
assert "sourceline" == soup.p.sourceline.name
assert "sourcepos" == soup.p.sourcepos.name
-@skipIf(
+@pytest.mark.skipif(
not LXML_PRESENT,
- "lxml seems not to be present, not testing its XML tree builder.")
+ reason="lxml seems not to be present, not testing its XML tree builder."
+)
class TestLXMLXMLTreeBuilder(SoupTest, XMLTreeBuilderSmokeTest):
"""See ``HTMLTreeBuilderSmokeTest``."""
@@ -150,6 +147,9 @@ class TestLXMLXMLTreeBuilder(SoupTest, XMLTreeBuilderSmokeTest):
}
+ @pytest.mark.skipif(
+ not SOUP_SIEVE_PRESENT, reason="Soup Sieve not installed"
+ )
def test_namespace_interaction_with_select_and_find(self):
# Demonstrate how namespaces interact with select* and
# find* methods.