We are switching our project to Python 3.12. We use pytest and httpretty in order to mock some requests. From Python 3.12 datetime.utcnow is deprecated: https://docs.python.org/3/library/datetime.html#datetime.datetime.utcnow
When running tests using pytest, warnings raise an exception and since datetime.utcnow is used by httpretty in a thread: https://github.com/gabrielfalcao/HTTPretty/blob/main/httpretty/core.py#L1077 the warning is not visible anywhere. httpretty does not fill the file with HTTP content and tests fail with something like this: ConnectionError: Error requesting 'http://localhost:9000/path': ProtocolError: ('Connection aborted.', RemoteDisconnected('Remote end closed connection without response')). It fails because http client gets an empty string from the file when trying to read the first line of HTTP response: https://github.com/python/cpython/blob/3.12/Lib/http/client.py#L285
It can be workarounded by adding an ignore to pytest.ini file.
We are switching our project to Python 3.12. We use
pytest
andhttpretty
in order to mock some requests. From Python 3.12datetime.utcnow
is deprecated: https://docs.python.org/3/library/datetime.html#datetime.datetime.utcnow When running tests usingpytest
, warnings raise an exception and sincedatetime.utcnow
is used by httpretty in a thread: https://github.com/gabrielfalcao/HTTPretty/blob/main/httpretty/core.py#L1077 the warning is not visible anywhere.httpretty
does not fill the file with HTTP content and tests fail with something like this:ConnectionError: Error requesting 'http://localhost:9000/path': ProtocolError: ('Connection aborted.', RemoteDisconnected('Remote end closed connection without response'))
. It fails because http client gets an empty string from the file when trying to read the first line of HTTP response: https://github.com/python/cpython/blob/3.12/Lib/http/client.py#L285It can be workarounded by adding an ignore to
pytest.ini
file.