jinja add tag
I have a script that will generate html using Jinja.

<!-- more html here -->
<ul id="someList">
  <li>Item 1</li>
  <li>Item 2</li>
<!-- more html here, too -->

I would like to make assertions like "assert that the html string has #someList and has 2 items: Item 1 and Item 2." without resorting to substring checking. e.g. 

assert 'ul id="someList"' in renderedHtml
assert 'Item 1' in renderedHtml
assert 'Item 2' in renderedHtml


I imagine something like,

parsedHtml = parse(renderedHtml)
assert someList := parsedHtml.findBySelector("ul#someList")
assert someList.contains("Item 1")
assert someList.contains("Item 2")

Is installing an additional dependency (e.g. BeautifulSoup) an  appropriate way to go about this?

Or does Jinja have a built-in functionality to help with these kinds of tests? I also use `pytest` if that matters.

This room is for discussion about this question.

Once logged in you can direct comments to any contributor here.

Enter question or answer id or url (and optionally further answer ids/urls from the same question) from

Separate each id/url with a space. No need to list your own answers; they will be imported automatically.