Do not output confusing errors during tests

Do not log the exception for Python 3 (and hide the `No handlers could
be found for logger "__main__"` report for Python 2). Avoid the "cat"
error message by checking for the file existence first.

Use a custom check_error function because assertRaisesRegex is not
available in Python 2.6.