File tree Expand file tree Collapse file tree 2 files changed +22
-2
lines changed Expand file tree Collapse file tree 2 files changed +22
-2
lines changed Original file line number Diff line number Diff line change 1
1
import asyncio
2
+ import os
2
3
import socket
3
- import unittest
4
4
import sys
5
+ import tempfile
6
+ import unittest
7
+ import uuid
5
8
6
9
from uvloop import _testbase as tb
7
10
@@ -155,6 +158,21 @@ def test_create_datagram_endpoint_sock(self):
155
158
tr .close ()
156
159
self .loop .run_until_complete (pr .done )
157
160
161
+ @unittest .skipIf (sys .version_info < (3 , 5 , 1 ),
162
+ "asyncio in 3.5.0 doesn't have the 'sock' argument" )
163
+ def test_create_datagram_endpoint_sock_unix_domain (self ):
164
+ tmp_file = os .path .join (tempfile .gettempdir (), str (uuid .uuid4 ()))
165
+ sock = socket .socket (socket .AF_UNIX , type = socket .SOCK_DGRAM )
166
+ sock .bind (tmp_file )
167
+
168
+ with sock :
169
+ f = self .loop .create_datagram_endpoint (
170
+ lambda : MyDatagramProto (loop = self .loop ), sock = sock )
171
+ tr , pr = self .loop .run_until_complete (f )
172
+ self .assertIsInstance (pr , MyDatagramProto )
173
+ tr .sendto (b'HELLO' , tmp_file )
174
+ tr .close ()
175
+ self .loop .run_until_complete (pr .done )
158
176
159
177
class Test_UV_UDP (_TestUDP , tb .UVTestCase ):
160
178
Original file line number Diff line number Diff line change
1
+ import socket
2
+
1
3
cdef class UDPTransport(UVBaseTransport):
2
4
3
5
def __cinit__ (self ):
@@ -141,7 +143,7 @@ cdef class UDPTransport(UVBaseTransport):
141
143
raise ValueError (
142
144
' Invalid address: must be None or {}' .format(self .address))
143
145
144
- if addr is not None :
146
+ if addr is not None and self .sock.family ! = socket.AF_UNIX :
145
147
addrinfo = __static_getaddrinfo_pyaddr(
146
148
addr[0 ], addr[1 ],
147
149
uv.AF_UNSPEC, self .sock.type, self .sock.proto, 0 )
You can’t perform that action at this time.
0 commit comments