mirror of
https://github.com/Hopiu/linkchecker.git
synced 2026-03-16 22:10:26 +00:00
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:
parent
d6936ceb91
commit
6d9061b00a
2 changed files with 15 additions and 4 deletions
|
|
@ -17,19 +17,27 @@
|
||||||
HTML parser implemented using Beautiful Soup and html.parser.
|
HTML parser implemented using Beautiful Soup and html.parser.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
from warnings import filterwarnings
|
import warnings
|
||||||
|
|
||||||
filterwarnings(
|
warnings.filterwarnings(
|
||||||
"ignore",
|
"ignore",
|
||||||
message="The soupsieve package is not installed. CSS selectors cannot be used.",
|
message="The soupsieve package is not installed. CSS selectors cannot be used.",
|
||||||
category=UserWarning,
|
category=UserWarning,
|
||||||
module="bs4",
|
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):
|
def make_soup(markup, from_encoding=None):
|
||||||
return BeautifulSoup(
|
return bs4.BeautifulSoup(
|
||||||
markup, "html.parser", from_encoding=from_encoding, multi_valued_attributes=None
|
markup, "html.parser", from_encoding=from_encoding, multi_valued_attributes=None
|
||||||
)
|
)
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,6 @@
|
||||||
[pytest]
|
[pytest]
|
||||||
testpaths = tests
|
testpaths = tests
|
||||||
addopts = -ra --tb=short
|
addopts = -ra --tb=short
|
||||||
|
filterwarnings =
|
||||||
|
ignore::bs4.MarkupResemblesLocatorWarning
|
||||||
|
ignore::bs4.builder.XMLParsedAsHTMLWarning
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue