Regression: localhost.localdomain default breaks name resolution
Describe the bug In version 1.2.1, the following update was made:
Fix bug in :meth:pytest_flask.fixtures.live_server where SESSION_COOKIE_DOMAIN was set to false due to original_server_name defaulting to "localhost". The new default is "localhost.localdomain".
This causes issues when we go to make requests to our Flask test server. Specifically we get errors that look like this:
WARNING urllib3.connectionpool:connectionpool.py:871 Retrying (Retry(total=0, connect=None, read=None, redirect=None, status=None)) after connection broken by 'NameResolutionError("<urllib3.connection.HTTPConnection object at 0x16dd5a4d0>: Failed to resolve 'localhost.localdomain' ([Errno 8] nodename nor servname provided, or not known)")': /graphql
When we make a request to url_for, we get back a URL that looks like http://localhost.localdomain/graphql instead of http://localhost/graphql
While I know I can add localhost.localdomain to my local /etc/hosts file, there are many docker images we're using in our CI pipelines that also do not know how to resolve this domain name.
Hello @dhay
The server_name is set to the default localhost.localdomain only when it's not explicitly specified. As a workaround I suggest to explicitly set server_name to the localhost in your test application config.
SERVER_NAME = 'localhost'
This is what I’ve done for the time being to work around the issue. That said, I’m not sure I understand the impetus for the change.
Same issue here. Our test suite (involving the live_server fixture) works on 1.2.0 and breaks after it.