1010import threading
1111
1212from test import support
13+ from test .support import os_helper
1314from test .support import socket_helper
1415from test .support import threading_helper
16+ from test .support import warnings_helper
1517from io import BytesIO
1618
1719if support .PGO :
@@ -92,7 +94,7 @@ def bind_af_aware(sock, addr):
9294 """Helper function to bind a socket according to its family."""
9395 if HAS_UNIX_SOCKETS and sock .family == socket .AF_UNIX :
9496 # Make sure the path doesn't exist.
95- support .unlink (addr )
97+ os_helper .unlink (addr )
9698 socket_helper .bind_unix_socket (sock , addr )
9799 else :
98100 sock .bind (addr )
@@ -369,14 +371,14 @@ def test_send(self):
369371class FileWrapperTest (unittest .TestCase ):
370372 def setUp (self ):
371373 self .d = b"It's not dead, it's sleeping!"
372- with open (support .TESTFN , 'wb' ) as file :
374+ with open (os_helper .TESTFN , 'wb' ) as file :
373375 file .write (self .d )
374376
375377 def tearDown (self ):
376- support .unlink (support .TESTFN )
378+ os_helper .unlink (os_helper .TESTFN )
377379
378380 def test_recv (self ):
379- fd = os .open (support .TESTFN , os .O_RDONLY )
381+ fd = os .open (os_helper .TESTFN , os .O_RDONLY )
380382 w = asyncore .file_wrapper (fd )
381383 os .close (fd )
382384
@@ -390,20 +392,20 @@ def test_recv(self):
390392 def test_send (self ):
391393 d1 = b"Come again?"
392394 d2 = b"I want to buy some cheese."
393- fd = os .open (support .TESTFN , os .O_WRONLY | os .O_APPEND )
395+ fd = os .open (os_helper .TESTFN , os .O_WRONLY | os .O_APPEND )
394396 w = asyncore .file_wrapper (fd )
395397 os .close (fd )
396398
397399 w .write (d1 )
398400 w .send (d2 )
399401 w .close ()
400- with open (support .TESTFN , 'rb' ) as file :
402+ with open (os_helper .TESTFN , 'rb' ) as file :
401403 self .assertEqual (file .read (), self .d + d1 + d2 )
402404
403405 @unittest .skipUnless (hasattr (asyncore , 'file_dispatcher' ),
404406 'asyncore.file_dispatcher required' )
405407 def test_dispatcher (self ):
406- fd = os .open (support .TESTFN , os .O_RDONLY )
408+ fd = os .open (os_helper .TESTFN , os .O_RDONLY )
407409 data = []
408410 class FileDispatcher (asyncore .file_dispatcher ):
409411 def handle_read (self ):
@@ -415,16 +417,16 @@ def handle_read(self):
415417
416418 def test_resource_warning (self ):
417419 # Issue #11453
418- fd = os .open (support .TESTFN , os .O_RDONLY )
420+ fd = os .open (os_helper .TESTFN , os .O_RDONLY )
419421 f = asyncore .file_wrapper (fd )
420422
421423 os .close (fd )
422- with support .check_warnings (('' , ResourceWarning )):
424+ with warnings_helper .check_warnings (('' , ResourceWarning )):
423425 f = None
424426 support .gc_collect ()
425427
426428 def test_close_twice (self ):
427- fd = os .open (support .TESTFN , os .O_RDONLY )
429+ fd = os .open (os_helper .TESTFN , os .O_RDONLY )
428430 f = asyncore .file_wrapper (fd )
429431 os .close (fd )
430432
@@ -804,10 +806,10 @@ class TestAPI_UseIPv6Sockets(BaseTestAPI):
804806class TestAPI_UseUnixSockets (BaseTestAPI ):
805807 if HAS_UNIX_SOCKETS :
806808 family = socket .AF_UNIX
807- addr = support .TESTFN
809+ addr = os_helper .TESTFN
808810
809811 def tearDown (self ):
810- support .unlink (self .addr )
812+ os_helper .unlink (self .addr )
811813 BaseTestAPI .tearDown (self )
812814
813815class TestAPI_UseIPv4Select (TestAPI_UseIPv4Sockets , unittest .TestCase ):
0 commit comments