test_exception_custom_html.py 510 B

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