assertInHTML fails when using simple quotes in the needle

Hi
I get a failure in assertInHTML with the following error:
AssertionError: False is not true : Couldn't find 'Bonjour Mr Freeze, c&#x27;est foo bar!<br>' in response

although the response contains:
Bonjour Mr Freeze, c'est foo bar!

In both cases, I am using the translation feature to build the message. In the template, I’m using
{% blocktranslate %}Hello {{invited}}, this is {{admin}}!{% endblocktranslate %}

and in the test, I’m using
self.assertInHTML(f'''{_("Hello %(invited)s, this is %(admin)s!")% {'invited': test_invite['invited'], 'admin' : sender.get_full_name()}}<br/>''', content)

It looks like the simple quote is translated to ’ in the response and to &#x27; in the test but anyway, from HTML point of view, this is the same and it should not fail.

Actually, this is not linked to the simple quote, I tried it in English and had the same error.
Finally, this is the way assertInHTML works: you cannot provide a simple string as needle, it won’t find it!
I had to add the the HTML element around the string and as there were many children to this HTML element, I had to tests them all at once :frowning:
It would be great if assertInHTML can check only a string…

That’s actually what assertContains does.

Thank you @KenWhitesell
I usually use assertContains instead of assertInHTML already but except if I missed something, I can’t use assertContains in my case because I am checking the HTML content of an email I generated, not an HTTP response.
Furthermore, I’m not sure at all assertContains behaves differently than assertInHTML with strings anyway: in case you need to check strings with HTML entities (like me with &#x27; ) I think you need to pass html=True and then you are using the same behavior as the assertInHTML one…

In that case, I’d probably use assertIn.

I’d either define the string-to-be-tested to have the html entities in it, or run that string through a function that converts the reserved characters to their entity equivalents.