File: test_howto_hooks.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 (11 lines) | stat: -rw-r--r-- 384 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
import requests

from pytest_httpserver import HTTPServer
from pytest_httpserver.hooks import Delay


def test_delay(httpserver: HTTPServer):
    # this adds 0.5 seconds delay to the server response
    httpserver.expect_request("/foo").with_post_hook(Delay(0.5)).respond_with_json({"example": "foo"})

    assert requests.get(httpserver.url_for("/foo")).json() == {"example": "foo"}