def METHOD_NAME(self):
    """Test that trailing whitespace after the error is removed"""
    m = mock_open()
    m.return_value.readlines.return_value = ['this is line 1\n', 'this is line 2\n', 'this is line 3\n', '  \n', '   \n', ' ']
    with patch('builtins.open', m):
        self.obj.ansible_pos = ('foo.yml', 5, 1)
        e = AnsibleError(self.message, self.obj)
        self.assertEqual(
            e.message,
            ("This is the error message\n\nThe error appears to be in 'foo.yml': line 5, column 1, but may\nbe elsewhere in the file depending on "
             "the exact syntax problem.\n\nThe offending line appears to be:\n\nthis is line 2\nthis is line 3\n^ here\n")
        )