Bläddra i källkod

Refactor DisableRedirectHandler

Unrud 3 år sedan
förälder
incheckning
0baf1dc908
1 ändrade filer med 6 tillägg och 21 borttagningar
  1. 6 21
      radicale/tests/test_server.py

+ 6 - 21
radicale/tests/test_server.py

@@ -28,7 +28,8 @@ import sys
 import threading
 import time
 from configparser import RawConfigParser
-from typing import Callable, Dict, NoReturn, Optional, Tuple, cast
+from http.client import HTTPMessage
+from typing import IO, Callable, Dict, Optional, Tuple, cast
 from urllib import request
 from urllib.error import HTTPError, URLError
 
@@ -40,26 +41,10 @@ from radicale.tests.helpers import configuration_to_dict, get_file_path
 
 
 class DisabledRedirectHandler(request.HTTPRedirectHandler):
-
-    # HACK: typeshed annotation are wrong for `fp` and `msg`
-    #       (https://github.com/python/typeshed/pull/5728)
-    #       `headers` is incompatible with `http.client.HTTPMessage`
-    #       (https://github.com/python/typeshed/issues/5729)
-    def http_error_301(self, req: request.Request, fp, code: int,
-                       msg, headers) -> NoReturn:
-        raise HTTPError(req.full_url, code, msg, headers, fp)
-
-    def http_error_302(self, req: request.Request, fp, code: int,
-                       msg, headers) -> NoReturn:
-        raise HTTPError(req.full_url, code, msg, headers, fp)
-
-    def http_error_303(self, req: request.Request, fp, code: int,
-                       msg, headers) -> NoReturn:
-        raise HTTPError(req.full_url, code, msg, headers, fp)
-
-    def http_error_307(self, req: request.Request, fp, code: int,
-                       msg, headers) -> NoReturn:
-        raise HTTPError(req.full_url, code, msg, headers, fp)
+    def redirect_request(
+            self, req: request.Request, fp: IO[bytes], code: int, msg: str,
+            headers: HTTPMessage, newurl: str) -> None:
+        return None
 
 
 class TestBaseServerRequests(BaseTest):