Skip to content

Commit

Permalink
Test passing various types to trio.socket.SocketType.{bind,connect}
Browse files Browse the repository at this point in the history
  • Loading branch information
regnarg committed Jul 31, 2024
1 parent 555eb5f commit a165b88
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/trio/_tests/test_socket.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import errno
import inspect
import os
from pathlib import Path
import socket as stdlib_socket
import sys
import tempfile
Expand Down Expand Up @@ -1077,7 +1078,7 @@ async def test_unix_domain_socket() -> None:
# Bind has a special branch to use a thread, since it has to do filesystem
# traversal. Maybe connect should too? Not sure.

async def check_AF_UNIX(path: str | bytes) -> None:
async def check_AF_UNIX(path: str | bytes | os.PathLike) -> None:
with tsocket.socket(family=tsocket.AF_UNIX) as lsock:
await lsock.bind(path)
lsock.listen(10)
Expand All @@ -1092,7 +1093,9 @@ async def check_AF_UNIX(path: str | bytes) -> None:
# length on macOS.
with tempfile.TemporaryDirectory() as tmpdir:
path = f"{tmpdir}/sock"
await check_AF_UNIX(path)
# Test passing various supported types as path
for test_path in [path, Path(path), os.fsencode(path)]:
await check_AF_UNIX(path)

try:
cookie = os.urandom(20).hex().encode("ascii")
Expand Down

0 comments on commit a165b88

Please sign in to comment.