You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Thank you for this plugin, which helps keep our tests fast and safe! One piece of information that can still leak out even when using it, though, is DNS lookups. It would be great if we could also block calls to socket.getaddrinfo in the same way.
I believe this can be done in a basic way by adding socket.getaddrinfo = guarded to the disable_socket() method here:
""" disable socket.socket to disable the Internet. useful in testing.
"""
defguarded(*args, **kwargs):
raiseSocketBlockedError()
socket.socket=guarded
...and perhaps updating the exception message to not specifically reference socket.socket.
I have not sent a PR for this because I don't know the pytest API well enough to understand how and when disable_socket is getting called, or how this should interact with socket_allow_hosts() further down — but if that's not a concern, I'd be happy to submit that change for consideration.
Thanks again!
The text was updated successfully, but these errors were encountered:
Thank you for this plugin, which helps keep our tests fast and safe! One piece of information that can still leak out even when using it, though, is DNS lookups. It would be great if we could also block calls to
socket.getaddrinfo
in the same way.I believe this can be done in a basic way by adding
socket.getaddrinfo = guarded
to thedisable_socket()
method here:pytest-socket/pytest_socket.py
Lines 73 to 80 in cb5e7c5
...and perhaps updating the exception message to not specifically reference
socket.socket
.I have not sent a PR for this because I don't know the pytest API well enough to understand how and when
disable_socket
is getting called, or how this should interact withsocket_allow_hosts()
further down — but if that's not a concern, I'd be happy to submit that change for consideration.Thanks again!
The text was updated successfully, but these errors were encountered: