fix tests failing with server name warnings

After pallets/werkzeug#1577, mismatched configured and real server
names will show a warning in addition to raising 404. This caused
tests that did this deliberately to fail.

This patch removes the pytest fixture we were using to fail on
warnings, instead using the standard `-Werror` option. This speeds
up the tests by ~3x.
This commit is contained in:
David Lord 2019-06-07 13:23:13 -07:00
parent 6369537a49
commit dbd4520ccb
No known key found for this signature in database
GPG key ID: 7A1C87E3F5BC42A8
5 changed files with 37 additions and 63 deletions

View file

@ -88,15 +88,10 @@ def test_proper_test_request_context(app):
assert flask.url_for('sub', _external=True) == \
'http://foo.localhost.localdomain:5000/'
try:
# suppress Werkzeug 0.15 warning about name mismatch
with pytest.warns(None):
with app.test_request_context('/', environ_overrides={'HTTP_HOST': 'localhost'}):
pass
except ValueError as e:
assert str(e) == (
"the server name provided "
"('localhost.localdomain:5000') does not match the "
"server name from the WSGI environment ('localhost')"
)
app.config.update(SERVER_NAME='localhost')
with app.test_request_context('/', environ_overrides={'SERVER_NAME': 'localhost'}):