Skip to content

Commit

Permalink
fix: ensure exception error is stringified (#17)
Browse files Browse the repository at this point in the history
  • Loading branch information
bdraco authored Dec 9, 2023
1 parent e9d049c commit 747cf1d
Showing 1 changed file with 17 additions and 17 deletions.
34 changes: 17 additions & 17 deletions tests/test_impl.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ async def test__single_addr_info_errors(m_socket: ModuleType) -> None:
def _socket(*args, **kw):
nonlocal idx, errors
idx += 1
raise OSError(errors[idx])
raise OSError(5, errors[idx])

m_socket.socket = _socket # type: ignore
addr_info = [
Expand Down Expand Up @@ -112,7 +112,7 @@ def _socket(*args, **kw):
nonlocal idx, errors
idx += 1
if idx == 1:
raise OSError(errors[idx])
raise OSError(5, errors[idx])
return mock_socket

m_socket.socket = _socket # type: ignore
Expand Down Expand Up @@ -155,7 +155,7 @@ def _socket(*args, **kw):
nonlocal idx, errors
idx += 1
if idx == 1:
raise OSError(errors[idx])
raise OSError(5, errors[idx])
return mock_socket

m_socket.socket = _socket # type: ignore
Expand Down Expand Up @@ -199,7 +199,7 @@ async def test__multiple_addr_all_fail_happy_eyeballs(
def _socket(*args, **kw):
nonlocal idx, errors
idx += 1
raise OSError(errors[idx])
raise OSError(5, errors[idx])

m_socket.socket = _socket # type: ignore
addr_info = [
Expand Down Expand Up @@ -237,7 +237,7 @@ async def test__ipv6_and_ipv4_happy_eyeballs_ipv6_fails(

def _socket(*args, **kw):
if kw["family"] == socket.AF_INET6:
raise OSError("ipv6 fail")
raise OSError(5, "ipv6 fail")
for attr in kw:
setattr(mock_socket, attr, kw[attr])
return mock_socket
Expand Down Expand Up @@ -280,7 +280,7 @@ async def test__ipv6_and_ipv4_happy_eyeballs_ipv4_fails(

def _socket(*args, **kw):
if kw["family"] == socket.AF_INET:
raise OSError("ipv4 fail")
raise OSError(5, "ipv4 fail")
for attr in kw:
setattr(mock_socket, attr, kw[attr])
return mock_socket
Expand Down Expand Up @@ -334,7 +334,7 @@ async def _sock_connect(
) -> None:
create_calls.append(address)
if address[0] == "dead:beef::":
raise OSError("ipv6 fail")
raise OSError(5, "ipv6 fail")

return None

Expand Down Expand Up @@ -395,7 +395,7 @@ async def _sock_connect(
) -> None:
create_calls.append(address)
if address[0] == "dead:beef::":
raise OSError("ipv6 fail")
raise OSError(5, "ipv6 fail")

return None

Expand Down Expand Up @@ -458,7 +458,7 @@ async def _sock_connect(
) -> None:
create_calls.append(address)
if address[0] == "dead:beef::":
raise OSError("ipv6 fail")
raise OSError(5, "ipv6 fail")

return None

Expand Down Expand Up @@ -512,7 +512,7 @@ async def _sock_connect(
) -> None:
create_calls.append(address)
if address[0] == "dead:beef::":
raise OSError("ipv6 fail")
raise OSError(5, "ipv6 fail")

return None

Expand Down Expand Up @@ -589,7 +589,7 @@ async def _sock_connect(
) -> None:
create_calls.append(address)
if address[0] == "dead:beef::":
raise OSError("ipv6 fail")
raise OSError(5, "ipv6 fail")

return None

Expand Down Expand Up @@ -665,7 +665,7 @@ def _socket(*args, **kw):
for attr in kw:
setattr(mock_socket, attr, kw[attr])
if kw["family"] == socket.AF_INET:
mock_socket.bind.side_effect = OSError("bind fail")
mock_socket.bind.side_effect = OSError(5, "bind fail")

return mock_socket

Expand All @@ -674,7 +674,7 @@ async def _sock_connect(
) -> None:
create_calls.append(address)
if address[0] == "dead:beef::":
raise OSError("ipv6 fail")
raise OSError(5, "ipv6 fail")

return None

Expand Down Expand Up @@ -752,7 +752,7 @@ def _socket(*args, **kw):
for attr in kw:
setattr(mock_socket, attr, kw[attr])
if kw["family"] == socket.AF_INET:
mock_socket.bind.side_effect = OSError("bind fail")
mock_socket.bind.side_effect = OSError(5, "bind fail")

return mock_socket

Expand All @@ -761,7 +761,7 @@ async def _sock_connect(
) -> None:
create_calls.append(address)
if address[0] == "dead:beef::":
raise OSError("ipv6 fail")
raise OSError(5, "ipv6 fail")

return None

Expand Down Expand Up @@ -843,7 +843,7 @@ async def _sock_connect(
) -> None:
create_calls.append(address)
if address[0] == "dead:beef::":
raise OSError("ipv6 fail")
raise OSError(5, "ipv6 fail")

return None

Expand Down Expand Up @@ -925,7 +925,7 @@ async def _sock_connect(
) -> None:
create_calls.append(address)
if address[0] == "dead:beef::":
raise OSError("ipv6 fail")
raise OSError(5, "ipv6 fail")

return None

Expand Down

0 comments on commit 747cf1d

Please sign in to comment.