class_docstr: A token stream is an iterable that yields :class:`Token`\s.  The
  parser however does not iterate over it but calls :meth:`next` to go
  one token ahead.  The current active token is stored as :attr:`current`.
class_docstr_tok: ["A","token","stream","is","an","iterable","that","yields",":","class",":","`","Token","`","\\s",".","The","parser","however","does","not","iterate","over","it","but","calls",":","meth",":","`","next","`","to","go","one","token","ahead",".","The","current","active","token","is","stored","as",":","attr",":","`","current","`","."]
docstr: Expect a given token type and return it.  This accepts the same
  argument as :meth:`jinja2.lexer.Token.test`.
docstr_tok: ["Expect","a","given","token","type","and","return","it",".","This","accepts","the","same","argument","as",":","meth",":","`","jinja2.lexer.Token.test","`","."]
code: def expect(self, expr: str) -> Token:
      """Expect a given token type and return it.  This accepts the same
      argument as :meth:`jinja2.lexer.Token.test`.
      """
      if not self.current.test(expr):
          expr = describe_token_expr(expr)
  
          if self.current.type is TOKEN_EOF:
              raise TemplateSyntaxError(
                  f"unexpected end of template, expected {expr!r}.",
                  self.current.lineno,
                  self.name,
                  self.filename,
              )
  
          raise TemplateSyntaxError(
              f"expected token {expr!r}, got {describe_token(self.current)!r}",
              self.current.lineno,
              self.name,
              self.filename,
          )
  
      return next(self)
  
imports: import re
  import typing
  from ast import literal_eval
  from collections import deque
  from sys import intern
  from ._identifier import pattern
  from .exceptions import TemplateSyntaxError
  from .utils import LRUCache
label_desc: Use image node_id 12 for calling the TokenStream obj's underlying member method code with example usage: obj.expect(expr) and returns: next