'Expect a given token type and return it.  This accepts the same
argument as :meth:`jinja2.lexer.Token.test`.'

def expect(self, expr):

    if (not self.current.test(expr)):
        expr = describe_token_expr(expr)
        if (self.current.type is TOKEN_EOF):
            raise TemplateSyntaxError(('unexpected    end    of    template,    expected    %r.' % expr), self.current.lineno, self.name, self.filename)
        raise TemplateSyntaxError(('expected    token    %r,    got    %r' % (expr, describe_token(self.current))), self.current.lineno, self.name, self.filename)
    try:
        return self.current
    finally:
        next(self)
