MCPcopy
hub / github.com/pallets/jinja / test

Method test

src/jinja2/lexer.py:277–290  ·  view source on GitHub ↗

Test a token against a token expression. This can either be a token type or ``'token_type:token_value'``. This can only test against string values and types.

(self, expr: str)

Source from the content-addressed store, hash-verified

275 return describe_token(self)
276
277 def test(self, expr: str) -> bool:
278 """Test a token against a token expression. This can either be a
279 token type or ``'token_type:token_value'``. This can only test
280 against string values and types.
281 """
282 # here we do a regular string equality check as test_any is usually
283 # passed an iterable of not interned strings.
284 if self.type == expr:
285 return True
286
287 if ":" in expr:
288 return expr.split(":", 1) == [self.type, self.value]
289
290 return False
291
292 def test_any(self, *iterable: str) -> bool:
293 """Test against multiple token expressions."""

Callers 11

test_anyMethod · 0.95
parseMethod · 0.45
parse_ifMethod · 0.45
parse_import_contextMethod · 0.45
parse_includeMethod · 0.45
parse_contextMethod · 0.45
parse_notMethod · 0.45
parse_compareMethod · 0.45
parse_testMethod · 0.45
next_ifMethod · 0.45
expectMethod · 0.45

Calls

no outgoing calls

Tested by 1

test_anyMethod · 0.76