diff --git a/tests/helpers/http.py b/tests/helpers/http.py index e7ded9f8..435bf414 100644 --- a/tests/helpers/http.py +++ b/tests/helpers/http.py @@ -59,3 +59,16 @@ def json_file_handler(data): pass return HTTPHandler + + +def error_handler(code, msg): + """Return an HTTP handler that always returns the given error code.""" + + class HTTPHandler(http.server.BaseHTTPRequestHandler): + def do_GET(self): + self.send_error(code, msg) + + def log_message(self, *args, **kwargs): + pass + + return HTTPHandler