caterpillar icon indicating copy to clipboard operation
caterpillar copied to clipboard

BeautifulSoup generating warnings during tests

Open mgiuca opened this issue 9 years ago • 0 comments

  1. ./run_tests.py py

Tests are generating this warning:

/usr/local/lib/python2.7/dist-packages/bs4/__init__.py:166: UserWarning: No parser was explicitly specified, so I'm using the best available HTML parser for this system ("lxml"). This usually isn't a problem, but if you run this code on another system, or in a different virtual environment, it may use a different parser and behave differently.

To get rid of this warning, change this:

 BeautifulSoup([your markup])

to this:

 BeautifulSoup([your markup], "lxml")

  markup_type=markup_type))

Most calls to BeautifulSoup pass 'html.parser' as the parser, but there are lots of calls to BeautifulSoup with no explicit parser, which is what this is warning about. We can go through and set all of them to 'html.parser'.

But the test in report_test.py, TestGenerateSummary.test_generate_summary fails if you use 'html.parser'. It passes if you use 'lxml', but this indicates a problem with the test if the choice of parser matters. And also it means we have an unspecified dependency on lxml. So this is a legitimate warning that we don't want to ignore.

mgiuca avatar Feb 25 '16 07:02 mgiuca