summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--bs4/tests/test_html5lib.py7
-rw-r--r--bs4/tests/test_lxml.py4
-rw-r--r--bs4/tests/test_tree.py8
3 files changed, 14 insertions, 5 deletions
diff --git a/bs4/tests/test_html5lib.py b/bs4/tests/test_html5lib.py
index b32ab30..de30bc8 100644
--- a/bs4/tests/test_html5lib.py
+++ b/bs4/tests/test_html5lib.py
@@ -7,6 +7,7 @@ try:
HTML5LIB_PRESENT = True
except ImportError as e:
HTML5LIB_PRESENT = False
+from bs4 import BeautifulSoup
from bs4.element import SoupStrainer
from . import (
HTML5TreeBuilderSmokeTest,
@@ -29,10 +30,12 @@ class TestHTML5LibBuilder(SoupTest, HTML5TreeBuilderSmokeTest):
strainer = SoupStrainer("b")
markup = "<p>A <b>bold</b> statement.</p>"
with warnings.catch_warnings(record=True) as w:
- soup = self.soup(markup, parse_only=strainer)
+ soup = BeautifulSoup(markup, "html5lib", parse_only=strainer)
assert soup.decode() == self.document_for(markup)
- assert "the html5lib tree builder doesn't support parse_only" in str(w[0].message)
+ [warning] = w
+ assert warning.filename == __file__
+ assert "the html5lib tree builder doesn't support parse_only" in str(warning.message)
def test_correctly_nested_tables(self):
"""html5lib inserts <tbody> tags where other parsers don't."""
diff --git a/bs4/tests/test_lxml.py b/bs4/tests/test_lxml.py
index 396ca0e..e88515c 100644
--- a/bs4/tests/test_lxml.py
+++ b/bs4/tests/test_lxml.py
@@ -68,7 +68,9 @@ class TestLXMLTreeBuilder(SoupTest, HTMLTreeBuilderSmokeTest):
with warnings.catch_warnings(record=True) as w:
soup = BeautifulStoneSoup("<b />")
assert "<b/>" == str(soup.b)
- assert "BeautifulStoneSoup class is deprecated" in str(w[0].message)
+ [warning] = w
+ assert warning.filename == __file__
+ assert "BeautifulStoneSoup class is deprecated" in str(warning.message)
def test_tracking_line_numbers(self):
# The lxml TreeBuilder cannot keep track of line numbers from
diff --git a/bs4/tests/test_tree.py b/bs4/tests/test_tree.py
index e456966..0c49cb4 100644
--- a/bs4/tests/test_tree.py
+++ b/bs4/tests/test_tree.py
@@ -1282,13 +1282,17 @@ class TestDeprecatedArguments(SoupTest):
[result] = soup.find_all(text='markup')
assert result == 'markup'
assert result.parent.name == 'b'
- msg = str(w[0].message)
+ [warning] = w
+ assert warning.filename == __file__
+ msg = str(warning.message)
assert msg == "The 'text' argument to find()-type methods is deprecated. Use 'string' instead."
def test_soupstrainer_constructor_string(self):
with warnings.catch_warnings(record=True) as w:
strainer = SoupStrainer(text="text")
assert strainer.text == 'text'
- msg = str(w[0].message)
+ [warning] = w
+ msg = str(warning.message)
+ assert warning.filename == __file__
assert msg == "The 'text' argument to the SoupStrainer constructor is deprecated. Use 'string' instead."