| 1 |
from __future__ import annotations |
| 2 |
|
| 3 |
import pytest |
| 4 |
|
| 5 |
from markupsafe import escape |
| 6 |
|
| 7 |
|
| 8 |
class CustomHtmlThatRaises: |
| 9 |
def __html__(self) -> str: |
| 10 |
raise ValueError(123) |
| 11 |
|
| 12 |
|
| 13 |
def test_exception_custom_html() -> None: |
| 14 |
"""Checks whether exceptions in custom __html__ implementations are |
| 15 |
propagated correctly. |
| 16 |
|
| 17 |
There was a bug in the native implementation at some point: |
| 18 |
https://github.com/pallets/markupsafe/issues/108 |
| 19 |
""" |
| 20 |
obj = CustomHtmlThatRaises() |
| 21 |
|
| 22 |
with pytest.raises(ValueError): |
| 23 |
escape(obj) |