Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion flask_testing/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
from urllib.request import urlopen
import multiprocessing

from urllib import unquote
from werkzeug import cached_property

# Use Flask's preferred JSON module so that our runtime behavior matches.
Expand Down Expand Up @@ -215,7 +216,7 @@ def assertRedirects(self, response, location):
:param location: relative URL (i.e. without **http://localhost**)
"""
self.assertTrue(response.status_code in (301, 302))
self.assertEqual(response.location, "http://localhost" + location)
self.assertEqual(unquote(response.location), "http://localhost" + location)

assert_redirects = assertRedirects

Expand Down
4 changes: 4 additions & 0 deletions tests/flask_app/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,10 @@ def bad_url():
def redirect_to_index():
return redirect(url_for("index"))

@app.route("/redirect-next/")
def redirect_from_somewhere():
return redirect(url_for("index", next='/somewhere/'))

@app.route("/ajax/")
def ajax():
return jsonify(name="test")
Expand Down
4 changes: 4 additions & 0 deletions tests/test_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,10 @@ def test_assert_redirects(self):
response = self.client.get("/redirect/")
self.assertRedirects(response, "/")

def test_assert_redirects_with_query(self):
response = self.client.get("/redirect-next/")
self.assertRedirects(response, "/?next=/somewhere/")

def test_assert_template_used(self):
try:
self.client.get("/template/")
Expand Down