
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'}}"
    )

    assert str(undefined_var_error) == expected_str


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'}}"
    )

    assert str(undefined_var_error) == expected_str

Create a jinja2 error in the test to ensure it has a message attribute
Create a jinja2 error in the test to ensure it has a message attribute

+ 
+ 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',
-         exceptions.CookiecutterException('Errors should never pass silently'),
+         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'}}"
      )
  
      assert str(undefined_var_error) == expected_str
  
Create a jinja2 error in the test to ensure it has a message attribute
## Code Before:

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'}}"
    )

    assert str(undefined_var_error) == expected_str

## Instruction:
Create a jinja2 error in the test to ensure it has a message attribute
## Code After:

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'}}"
    )

    assert str(undefined_var_error) == expected_str
