File: test_howto_url_matcher.py

package info (click to toggle)
pytest-httpserver 1.1.3-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 908 kB
  • sloc: python: 2,382; makefile: 77; sh: 21
file content (14 lines) | stat: -rw-r--r-- 390 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
from pytest_httpserver import HTTPServer
from pytest_httpserver import URIPattern


class PrefixMatch(URIPattern):
    def __init__(self, prefix: str):
        self.prefix = prefix

    def match(self, uri):
        return uri.startswith(self.prefix)


def test_uripattern_object(httpserver: HTTPServer):
    httpserver.expect_request(PrefixMatch("/foo")).respond_with_json({"foo": "bar"})