Join GitHub today
GitHub is home to over 36 million developers working together to host and review code, manage projects, and build software together.Sign up
Test client redirect resets path info in 0.15 #1498
Pull request #1402 changes the redirect handling in werkzeug.test.Client and seems to reuse the
I have a multi-tenant application which resolves the tenant from the first path element in a middleware with
Here is a test application which demonstrates this problem:
from flask import Flask, redirect, url_for from werkzeug.test import Client from werkzeug.wrappers import BaseResponse from werkzeug.wsgi import pop_path_info app = Flask(__name__) @app.route("/first") def first(): return redirect(url_for('.second')) @app.route("/second") def second(): return b'hello' client = Client(app, BaseResponse) r = client.get('/first', follow_redirects=True) assert r.data == b'hello' def middleware(environ, start_response): print('Before pop_path_info(): %s' % environ['PATH_INFO']) pop_path_info(environ) print('After pop_path_info(): %s' % environ['PATH_INFO']) return app(environ, start_response) client = Client(middleware, BaseResponse) r = client.get('/tenant/first', follow_redirects=True) assert r.data == b'hello'