10
10
import threading
11
11
12
12
from test import support
13
+ from test .support import os_helper
13
14
from io import BytesIO
14
15
15
16
if support .PGO :
@@ -91,7 +92,7 @@ def bind_af_aware(sock, addr):
91
92
"""Helper function to bind a socket according to its family."""
92
93
if HAS_UNIX_SOCKETS and sock .family == socket .AF_UNIX :
93
94
# Make sure the path doesn't exist.
94
- support .unlink (addr )
95
+ os_helper .unlink (addr )
95
96
support .bind_unix_socket (sock , addr )
96
97
else :
97
98
sock .bind (addr )
@@ -368,14 +369,14 @@ def test_send(self):
368
369
class FileWrapperTest (unittest .TestCase ):
369
370
def setUp (self ):
370
371
self .d = b"It's not dead, it's sleeping!"
371
- with open (support .TESTFN , 'wb' ) as file :
372
+ with open (os_helper .TESTFN , 'wb' ) as file :
372
373
file .write (self .d )
373
374
374
375
def tearDown (self ):
375
- support .unlink (support .TESTFN )
376
+ os_helper .unlink (os_helper .TESTFN )
376
377
377
378
def test_recv (self ):
378
- fd = os .open (support .TESTFN , os .O_RDONLY )
379
+ fd = os .open (os_helper .TESTFN , os .O_RDONLY )
379
380
w = asyncore .file_wrapper (fd )
380
381
os .close (fd )
381
382
@@ -389,20 +390,20 @@ def test_recv(self):
389
390
def test_send (self ):
390
391
d1 = b"Come again?"
391
392
d2 = b"I want to buy some cheese."
392
- fd = os .open (support .TESTFN , os .O_WRONLY | os .O_APPEND )
393
+ fd = os .open (os_helper .TESTFN , os .O_WRONLY | os .O_APPEND )
393
394
w = asyncore .file_wrapper (fd )
394
395
os .close (fd )
395
396
396
397
w .write (d1 )
397
398
w .send (d2 )
398
399
w .close ()
399
- with open (support .TESTFN , 'rb' ) as file :
400
+ with open (os_helper .TESTFN , 'rb' ) as file :
400
401
self .assertEqual (file .read (), self .d + d1 + d2 )
401
402
402
403
@unittest .skipUnless (hasattr (asyncore , 'file_dispatcher' ),
403
404
'asyncore.file_dispatcher required' )
404
405
def test_dispatcher (self ):
405
- fd = os .open (support .TESTFN , os .O_RDONLY )
406
+ fd = os .open (os_helper .TESTFN , os .O_RDONLY )
406
407
data = []
407
408
class FileDispatcher (asyncore .file_dispatcher ):
408
409
def handle_read (self ):
@@ -414,7 +415,7 @@ def handle_read(self):
414
415
415
416
def test_resource_warning (self ):
416
417
# Issue #11453
417
- fd = os .open (support .TESTFN , os .O_RDONLY )
418
+ fd = os .open (os_helper .TESTFN , os .O_RDONLY )
418
419
f = asyncore .file_wrapper (fd )
419
420
420
421
os .close (fd )
@@ -423,7 +424,7 @@ def test_resource_warning(self):
423
424
support .gc_collect ()
424
425
425
426
def test_close_twice (self ):
426
- fd = os .open (support .TESTFN , os .O_RDONLY )
427
+ fd = os .open (os_helper .TESTFN , os .O_RDONLY )
427
428
f = asyncore .file_wrapper (fd )
428
429
os .close (fd )
429
430
@@ -803,10 +804,10 @@ class TestAPI_UseIPv6Sockets(BaseTestAPI):
803
804
class TestAPI_UseUnixSockets (BaseTestAPI ):
804
805
if HAS_UNIX_SOCKETS :
805
806
family = socket .AF_UNIX
806
- addr = support .TESTFN
807
+ addr = os_helper .TESTFN
807
808
808
809
def tearDown (self ):
809
- support .unlink (self .addr )
810
+ os_helper .unlink (self .addr )
810
811
BaseTestAPI .tearDown (self )
811
812
812
813
class TestAPI_UseIPv4Select (TestAPI_UseIPv4Sockets , unittest .TestCase ):
0 commit comments