Skip to content

Commit

Permalink
remove ephemeral-port-reserve
Browse files Browse the repository at this point in the history
  • Loading branch information
graingert committed Jan 7, 2025
1 parent e53e9eb commit 3d626c9
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
3 changes: 1 addition & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,7 @@ test = [
uvloop >= 0.21; platform_python_implementation == 'CPython' \
and platform_system != 'Windows' \
and python_version < '3.14'\
""",
"ephemeral-port-reserve >= 1.1.4",
"""
]
doc = [
"packaging",
Expand Down
15 changes: 8 additions & 7 deletions tests/test_sockets.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
from threading import Thread
from typing import TYPE_CHECKING, Any, Literal, NoReturn, TypeVar, cast

import ephemeral_port_reserve
import psutil
import pytest
from _pytest.fixtures import SubRequest
Expand Down Expand Up @@ -359,10 +358,13 @@ async def test_happy_eyeballs_refcycles(self, anyio_backend_name: str) -> None:
"asyncio.BaseEventLoop.create_connection creates refcycles on py 3.9"
)
ip = "127.0.0.1"
port = ephemeral_port_reserve.reserve(ip=ip)
with socket.socket(AddressFamily.AF_INET6) as dummy_socket:
dummy_socket.bind(("::", 0))
free_port = dummy_socket.getsockname()[1]

exc = None
try:
async with await connect_tcp(ip, port):
async with await connect_tcp(ip, free_port):
pass
except OSError as e:
exc = e.__cause__
Expand All @@ -385,10 +387,9 @@ async def test_connection_refused(
exception_class: type[ExceptionGroup] | type[ConnectionRefusedError],
fake_localhost_dns: None,
) -> None:
dummy_socket = socket.socket(AddressFamily.AF_INET6)
dummy_socket.bind(("::", 0))
free_port = dummy_socket.getsockname()[1]
dummy_socket.close()
with socket.socket(AddressFamily.AF_INET6) as dummy_socket:
dummy_socket.bind(("::", 0))
free_port = dummy_socket.getsockname()[1]

with pytest.raises(OSError) as exc:
await connect_tcp(target, free_port)
Expand Down

0 comments on commit 3d626c9

Please sign in to comment.