Skip to content

Commit

Permalink
Refactor DisableRedirectHandler
Browse files Browse the repository at this point in the history
  • Loading branch information
Unrud committed Mar 22, 2022
1 parent 47e42a4 commit 0baf1dc
Showing 1 changed file with 6 additions and 21 deletions.
27 changes: 6 additions & 21 deletions radicale/tests/test_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@
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

Expand All @@ -40,26 +41,10 @@


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):
Expand Down

0 comments on commit 0baf1dc

Please sign in to comment.