'Check that compiling code raises SyntaxError with errtext.
errtest is a regular expression that must be present in the
test of the exception raised.  If subclass is specified it
is the expected subclass of SyntaxError (e.g. IndentationError).'

def _check_error(self, code, errtext, filename='<testcase>', mode='exec', subclass=None):

    try:
        compile(code, filename, mode)
    except SyntaxError as err:
        if (subclass and (not isinstance(err, subclass))):
            self.fail(('SyntaxError    is    not    a    %s' % subclass.__name__))
        mo = re.search(errtext, str(err))
        if (mo is None):
            self.fail(("%s    did    not    contain    '%r'" % (err, errtext)))
    else:
        self.fail('compile()    did    not    raise    SyntaxError')
