aboutsummaryrefslogtreecommitdiffstats
path: root/contrib/python/MarkupSafe/py2/tests/test_exception_custom_html.py
blob: 5f9ffde438d5a880052b585b7ccb263426f8edd5 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
# -*- coding: utf-8 -*-
import pytest

from markupsafe import escape


class CustomHtmlThatRaises(object):
    def __html__(self):
        raise ValueError(123)


def test_exception_custom_html():
    """Checks whether exceptions in custom __html__ implementations are
    propagated correctly.

    There was a bug in the native implementation at some point:
    https://github.com/pallets/markupsafe/issues/108
    """
    obj = CustomHtmlThatRaises()
    with pytest.raises(ValueError):
        escape(obj)