Ignore bs4 markup and XML parser warnings

XMLParsedAsHTMLWarning: It looks like you're parsing an XML document
using an HTML parser.

MarkupResemblesLocatorWarning: The input looks more like a filename than
markup.

MarkupResemblesLocatorWarning: The input looks more like a URL than
markup.
This commit is contained in:
Chris Mayo 2022-09-02 19:29:11 +01:00
parent d6936ceb91
commit 6d9061b00a
2 changed files with 15 additions and 4 deletions

View file

@ -17,19 +17,27 @@
HTML parser implemented using Beautiful Soup and html.parser.
"""
from warnings import filterwarnings
import warnings
filterwarnings(
warnings.filterwarnings(
"ignore",
message="The soupsieve package is not installed. CSS selectors cannot be used.",
category=UserWarning,
module="bs4",
)
from bs4 import BeautifulSoup
import bs4
warnings.simplefilter(
'ignore', bs4.MarkupResemblesLocatorWarning
)
warnings.simplefilter(
'ignore', bs4.builder.XMLParsedAsHTMLWarning
)
def make_soup(markup, from_encoding=None):
return BeautifulSoup(
return bs4.BeautifulSoup(
markup, "html.parser", from_encoding=from_encoding, multi_valued_attributes=None
)

View file

@ -1,3 +1,6 @@
[pytest]
testpaths = tests
addopts = -ra --tb=short
filterwarnings =
ignore::bs4.MarkupResemblesLocatorWarning
ignore::bs4.builder.XMLParsedAsHTMLWarning