from unittest.mock import patch

import pytest

from flufl.i18n._expand import expand


class FailingTemplateClass:
    def __init__(self, template):
        self.template = template

    def safe_substitute(self, *args, **kws):
        raise TypeError


def test_exception():
    with patch('flufl.i18n._expand.log.exception') as log:
        with pytest.raises(TypeError):
            expand('my-template', {}, FailingTemplateClass)
    log.assert_called_once_with('broken template: %s', 'my-template')
