test_exception_custom_html.py 453 B

123456789101112131415161718
  1. import pytest
  2. class CustomHtmlThatRaises:
  3. def __html__(self):
  4. raise ValueError(123)
  5. def test_exception_custom_html(escape):
  6. """Checks whether exceptions in custom __html__ implementations are
  7. propagated correctly.
  8. There was a bug in the native implementation at some point:
  9. https://github.com/pallets/markupsafe/issues/108
  10. """
  11. obj = CustomHtmlThatRaises()
  12. with pytest.raises(ValueError):
  13. escape(obj)