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

Method test

src/werkzeug/routing/map.py:666–681  ·  view source on GitHub ↗

Test if a rule would match. Works like `match` but returns `True` if the URL matches, or `False` if it does not exist. :param path_info: the path info to use for matching. Overrides the path info specified on binding. :param method: the HTTP metho

(self, path_info: str | None = None, method: str | None = None)

Source from the content-addressed store, hash-verified

664 return rule.endpoint, rv
665
666 def test(self, path_info: str | None = None, method: str | None = None) -> bool:
667 """Test if a rule would match. Works like `match` but returns `True`
668 if the URL matches, or `False` if it does not exist.
669
670 :param path_info: the path info to use for matching. Overrides the
671 path info specified on binding.
672 :param method: the HTTP method used for matching. Overrides the
673 method specified on binding.
674 """
675 try:
676 self.match(path_info, method)
677 except RequestRedirect:
678 pass
679 except HTTPException:
680 return False
681 return True
682
683 def allowed_methods(self, path_info: str | None = None) -> t.Iterable[str]:
684 """Returns the valid methods that match for a given path.

Callers

nothing calls this directly

Calls 1

matchMethod · 0.95

Tested by

no test coverage detected