Skip to content

Commit

Permalink
[fix] issue when upgrading from werkzeug v2.0.3 to v2.1.0
Browse files Browse the repository at this point in the history
In v2.1.0 werkzeug [1] fixed an issue [2] to keep relative redirect locations by
default [3].  Since relative locations are returned, we need to fix out test
cases to avoid AssertionErrors like this one::

    ======================================================================
    FAIL: test_index_html_get (tests.unit.test_webapp.ViewsTestCase)
    ----------------------------------------------------------------------
    Traceback (most recent call last):
    File "/home/runner/work/searxng/searxng/tests/unit/test_webapp.py", line 105, in test_index_html_get
      self.assertEqual(result.location, 'http://localhost/search?q=test')
    AssertionError: '/search?q=test' != 'http://localhost/search?q=test'
    - /search?q=test
    + http://localhost/search?q=test

[1] https://werkzeug.palletsprojects.com/
[2] pallets/werkzeug#2352 fixed in
[3] pallets/werkzeug#2354

Related-to: #1039 (comment)
Signed-off-by: Markus Heiser <markus.heiser@darmarit.de>
  • Loading branch information
return42 committed Apr 1, 2022
1 parent fd67df7 commit 6c747c4
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions tests/unit/test_webapp.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,12 +97,12 @@ def test_index_empty(self):
def test_index_html_post(self):
result = self.app.post('/', data={'q': 'test'})
self.assertEqual(result.status_code, 308)
self.assertEqual(result.location, 'http://localhost/search')
self.assertEqual(result.location, '/search')

def test_index_html_get(self):
result = self.app.post('/?q=test')
self.assertEqual(result.status_code, 308)
self.assertEqual(result.location, 'http://localhost/search?q=test')
self.assertEqual(result.location, '/search?q=test')

def test_search_empty_html(self):
result = self.app.post('/search', data={'q': ''})
Expand Down

0 comments on commit 6c747c4

Please sign in to comment.