async def get_server_socket(): name = Path() / tempfile.gettempdir() / "test.sock" try: await name.unlink() except OSError: pass serv_sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) serv_sock.bind(fspath(name)) # bpo-32562 serv_sock.listen(1) return name, serv_sock
async def test_open_file_can_open_path(path): async with await trio.open_file(path, 'w') as f: assert f.name == fspath(path)
def __fspath__(self): return fspath(self._wrapped)
async def test_open_unix_socket(): name, serv_sock = await get_server_socket() unix_socket = await open_unix_socket(fspath(name)) await _do_test_on_sock(serv_sock, unix_socket)
def path(tmpdir): return fspath(tmpdir.join('test'))