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
Fix pytest-socket raises IndexError with httpx #85
Conversation
Code Climate has analyzed commit e8ddd80 and detected 0 issues on this pull request. View more on Code Climate. |
Thanks for the detailed report! I can't help but wonder that there's something else going on here - I've seen this behavior somewhere else and I can't recall what triggered it, but I don't think it was specific to the httpx library. I think an alternate solution could be: try:
is_unix_socket = args[0] == socket.AF_UNIX if args else None
except AttributeError: which would likely solve the same issue, but I think your approach is more Pythonic. i wish I remembered how that was triggered, so would be able to not have to include another external package for testing, but until I can recall, this will do. Thanks! |
@miketheman This is also triggered by
|
@ljodal Thanks for the report - can you try out the plugin with the latest code on |
@miketheman It works with latest main. I'd argue that as if 'family' in kwargs:
family = kwargs['family']
elif args:
family = args[0]
else:
# This seems to be the default?
family = socket.AF_INET
try:
is_unix_socket = family == socket.AF_UNIX
except AttributeError:
is_unix_socket = False Or at least adding a check in kwargs: try:
family = kwargs['family'] if 'family' in kwargs else args[0]
is_unix_socket = family == socket.AF_UNIX
except (AttributeError, IndexError):
is_unix_socket = False |
Ah, great! Should've checked |
Closes #84