Fix pytest-socket raises IndexError with httpx#85
Fix pytest-socket raises IndexError with httpx#85miketheman merged 1 commit intomiketheman:mainfrom ollipa:main
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 = FalseOr 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