Skip to content

Commit

Permalink
Merge branch 'master' into fix-to-process-on-windows
Browse files Browse the repository at this point in the history
  • Loading branch information
agronholm committed Jun 8, 2024
2 parents c86d24f + a096a4e commit 1248bcb
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 23 deletions.
3 changes: 1 addition & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -97,13 +97,12 @@ disallow_subclassing_any = false
show_error_codes = true

[tool.pytest.ini_options]
addopts = "-rsx --tb=short --strict-config --strict-markers -p anyio -p no:asyncio -p no:trio"
addopts = "-rsfE --tb=short --strict-config --strict-markers -p anyio -p no:asyncio -p no:trio"
testpaths = ["tests"]
xfail_strict = true
# Ignore resource warnings due to a CPython/Windows bug (https://bugs.python.org/issue44428)
filterwarnings = [
"error",
"ignore:unclosed <socket.socket.*:ResourceWarning",
"ignore:unclosed transport <_ProactorSocketTransport.*:ResourceWarning",
"ignore:ast.Str is deprecated:DeprecationWarning",
"ignore:Attribute s is deprecated:DeprecationWarning",
Expand Down
43 changes: 22 additions & 21 deletions tests/test_sockets.py
Original file line number Diff line number Diff line change
Expand Up @@ -491,26 +491,27 @@ async def test_unretrieved_future_exception_server_crash(
def serve() -> None:
sock, addr = server_sock.accept()
event.wait(3)
sock.close()
del sock
gc.collect()

server_sock = socket.socket(family, socket.SOCK_STREAM)
server_sock.settimeout(1)
server_sock.bind(("localhost", 0))
server_sock.listen()
server_addr = server_sock.getsockname()[:2]
event = threading.Event()
thread = Thread(target=serve)
thread.start()
async with await connect_tcp(*server_addr) as stream:
await stream.send(b"GET")
event.set()
with pytest.raises(BrokenResourceError):
await stream.receive()
with socket.socket(family, socket.SOCK_STREAM) as server_sock:
server_sock.settimeout(1)
server_sock.bind(("localhost", 0))
server_sock.listen()
server_addr = server_sock.getsockname()[:2]
event = threading.Event()
thread = Thread(target=serve)
thread.start()
async with await connect_tcp(*server_addr) as stream:
await stream.send(b"GET")
event.set()
with pytest.raises(BrokenResourceError):
await stream.receive()

thread.join()
gc.collect()
assert not caplog.text
thread.join()
gc.collect()
assert not caplog.text


@pytest.mark.network
Expand Down Expand Up @@ -1042,12 +1043,12 @@ async def test_connecting_using_bytes(
)
async def test_connecting_with_non_utf8(self, socket_path: Path) -> None:
actual_path = str(socket_path).encode() + b"\xf0"
server = socket.socket(socket.AF_UNIX)
server.bind(actual_path)
server.listen(1)
with socket.socket(socket.AF_UNIX) as server:
server.bind(actual_path)
server.listen(1)

async with await connect_unix(actual_path):
pass
async with await connect_unix(actual_path):
pass


@pytest.mark.skipif(
Expand Down

0 comments on commit 1248bcb

Please sign in to comment.