<commit_before># -*- coding: utf-8 -*-

from cookiecutter import exceptions


def test_undefined_variable_to_str():
    undefined_var_error = exceptions.UndefinedVariableInTemplate(
        'Beautiful is better than ugly',
        exceptions.CookiecutterException('Errors should never pass silently'),
        {'cookiecutter': {'foo': 'bar'}}
    )

    expected_str = (
        "Beautiful is better than ugly. "
        "Error message: Errors should never pass silently. "
        "Context: {'cookiecutter': {'foo': 'bar'}}"
    )
<commit_msg>Create a jinja2 error in the test to ensure it has a message attribute<commit_after># -*- coding: utf-8 -*-

from jinja2.exceptions import UndefinedError

from cookiecutter import exceptions


def test_undefined_variable_to_str():
    undefined_var_error = exceptions.UndefinedVariableInTemplate(
        'Beautiful is better than ugly',
        UndefinedError('Errors should never pass silently'),
        {'cookiecutter': {'foo': 'bar'}}
    )

    expected_str = (
        "Beautiful is better than ugly. "
        "Error message: Errors should never pass silently. "
        "Context: {'cookiecutter': {'foo': 'bar'}}"
    )

{'fraction_non_alphanumeric': 0.11082693947144075, 'fraction_numerical': 0.0034100596760443308, 'mean_word_length': 3.3003663003663, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2726726', 'n_tokens_mistral': 334, 'n_tokens_neox': 324, 'n_words': 99}