diff --git a/tests/end2end/fixtures/webserver_sub.py b/tests/end2end/fixtures/webserver_sub.py index 4ec4619f7..f0720bab6 100644 --- a/tests/end2end/fixtures/webserver_sub.py +++ b/tests/end2end/fixtures/webserver_sub.py @@ -32,6 +32,7 @@ import time import signal import os import threading +from http import HTTPStatus import cheroot.wsgi import flask @@ -112,7 +113,7 @@ def redirect_n_times(n): def relative_redirect(): """302 Redirect once.""" response = app.make_response('') - response.status_code = 302 + response.status_code = HTTPStatus.FOUND response.headers['Location'] = flask.url_for('root') return response @@ -121,7 +122,7 @@ def relative_redirect(): def absolute_redirect(): """302 Redirect once.""" response = app.make_response('') - response.status_code = 302 + response.status_code = HTTPStatus.FOUND response.headers['Location'] = flask.url_for('root', _external=True) return response @@ -133,7 +134,7 @@ def redirect_to(): # werkzeug from "fixing" the URL. This endpoint should set the Location # header to the exact string supplied. response = app.make_response('') - response.status_code = 302 + response.status_code = HTTPStatus.FOUND response.headers['Location'] = flask.request.args['url'].encode('utf-8') return response @@ -149,7 +150,7 @@ def content_size(): response = flask.Response(generate_bytes(), headers={ "Content-Type": "application/octet-stream", }) - response.status_code = 200 + response.status_code = HTTPStatus.OK return response @@ -163,7 +164,7 @@ def twenty_mb(): "Content-Type": "application/octet-stream", "Content-Length": str(20 * 1024 * 1024), }) - response.status_code = 200 + response.status_code = HTTPStatus.OK return response @@ -174,7 +175,7 @@ def internal_error_attachment(): "Content-Type": "application/octet-stream", "Content-Disposition": 'inline; filename="attachment.jpg"', }) - response.status_code = 500 + response.status_code = HTTPStatus.INTERNAL_SERVER_ERROR return response @@ -199,7 +200,7 @@ def basic_auth(user='user', passwd='passwd'): auth = flask.request.authorization if not auth or auth.username != user or auth.password != passwd: r = flask.make_response() - r.status_code = 401 + r.status_code = HTTPStatus.UNAUTHORIZED r.headers = {'WWW-Authenticate': 'Basic realm="Fake Realm"'} return r @@ -222,14 +223,14 @@ def drip(): "Content-Type": "application/octet-stream", "Content-Length": str(numbytes), }) - response.status_code = 200 + response.status_code = HTTPStatus.OK return response @app.route('/404') def status_404(): r = flask.make_response() - r.status_code = 404 + r.status_code = HTTPStatus.NOT_FOUND return r