'Context manager assertion which asserts that the yielded code raises an
appropriate validation exception and message.
Asserts:
- That the exception is an instance of ParseError.
- That the exception message\'s key matches the passed validation error
key.
- That the exception message\'s message string matches the message
string for the passed validation error key.'

@contextmanager
def assertValidationError(self, key, **kwargs):

    try:
        (yield)
    except Exception as e:
        expected_message = ExtensionValidator.errors[key]
        if kwargs:
            expected_message = (expected_message % kwargs)
        eq_(e.__class__, ParseError)
        eq_(e.detail['detail']['key'], key)
        eq_(e.detail['detail']['message'], expected_message)
        if kwargs:
            eq_(e.detail['detail']['params'], kwargs)
    else:
        self.fail('Does    not    raise    a    ParseError.')
