Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

httpretty silently fails with Python 3.12 #474

Open
kfrydel opened this issue Oct 23, 2023 · 0 comments
Open

httpretty silently fails with Python 3.12 #474

kfrydel opened this issue Oct 23, 2023 · 0 comments

Comments

@kfrydel
Copy link

kfrydel commented Oct 23, 2023

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant