Refs #31040 -- Used 402 HTTP status in middleware_exceptions tests.

HTTP status code 418 - "I'm a Teaport" was added to http.HTTPStatus in
Python 3.9.0a5 [1] that caused failures in middleware_exceptions tests.

This changes HTTP status used in middleware_exceptions tests to 402,
which exists in all supported versions of Python.

[1] https://docs.python.org/3.9/whatsnew/3.9.html#http
This commit is contained in:
Mariusz Felisiak 2020-03-31 12:09:17 +02:00 committed by GitHub
parent 8aa71f4e87
commit 195e0cb170
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 23 additions and 23 deletions

View file

@ -96,18 +96,18 @@ class NotFoundMiddleware(BaseMiddleware):
raise Http404('not found')
class TeapotMiddleware(BaseMiddleware):
class PaymentMiddleware(BaseMiddleware):
def __call__(self, request):
response = self.get_response(request)
response.status_code = 418
response.status_code = 402
return response
@async_only_middleware
def async_teapot_middleware(get_response):
def async_payment_middleware(get_response):
async def middleware(request):
response = await get_response(request)
response.status_code = 418
response.status_code = 402
return response
return middleware
@ -119,7 +119,7 @@ class SyncAndAsyncMiddleware(BaseMiddleware):
@sync_only_middleware
class DecoratedTeapotMiddleware(TeapotMiddleware):
class DecoratedPaymentMiddleware(PaymentMiddleware):
pass