From 2c62a566c5dbb83b09b44ab716ae7300bc5be705 Mon Sep 17 00:00:00 2001 From: "Nathaniel J. Smith" Date: Fri, 11 Aug 2017 13:18:20 -0700 Subject: [PATCH] Use a shorter temporary directory name for AF_UNIX sockets --- trio/tests/test_testing.py | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/trio/tests/test_testing.py b/trio/tests/test_testing.py index 6e12b5d49a..0cce9c6e17 100644 --- a/trio/tests/test_testing.py +++ b/trio/tests/test_testing.py @@ -2,6 +2,7 @@ import time from math import inf +import tempfile import pytest @@ -776,7 +777,7 @@ async def two_way_stream_maker(): await check_two_way_stream(two_way_stream_maker, two_way_stream_maker) -async def test_open_stream_to_socket_listener(tmpdir): +async def test_open_stream_to_socket_listener(): async def check(listener): async with listener: client_stream = await open_stream_to_socket_listener(listener) @@ -807,7 +808,10 @@ async def check(listener): if hasattr(tsocket, "AF_UNIX"): # Listener bound to Unix-domain socket sock = tsocket.socket(family=tsocket.AF_UNIX) - path = str(tmpdir / "sock") - sock.bind(path) - sock.listen(10) - await check(SocketListener(sock)) + # can't use pytest's tmpdir; if we try then MacOS says "OSError: + # AF_UNIX path too long" + with tempfile.TemporaryDirectory() as tmpdir: + path = "{}/sock".format(tmpdir) + sock.bind(path) + sock.listen(10) + await check(SocketListener(sock))