mirror of
https://github.com/python/cpython.git
synced 2025-08-31 05:58:33 +00:00
gh-93852: Add test.support.create_unix_domain_name() (#93914)
test_asyncio, test_logging, test_socket and test_socketserver now create AF_UNIX domains in the current directory to no longer fail with OSError("AF_UNIX path too long") if the temporary directory (the TMPDIR environment variable) is too long. Modify the following tests to use create_unix_domain_name(): * test_asyncio * test_logging * test_socket * test_socketserver test_asyncio.utils: remove unused time import.
This commit is contained in:
parent
ffc228dd4e
commit
c5b750dc0b
7 changed files with 82 additions and 86 deletions
|
@ -1828,12 +1828,6 @@ class SocketHandlerTest(BaseTest):
|
|||
time.sleep(self.sock_hdlr.retryTime - now + 0.001)
|
||||
self.root_logger.error('Nor this')
|
||||
|
||||
def _get_temp_domain_socket():
|
||||
fn = make_temp_file(prefix='test_logging_', suffix='.sock')
|
||||
# just need a name - file can't be present, or we'll get an
|
||||
# 'address already in use' error.
|
||||
os.remove(fn)
|
||||
return fn
|
||||
|
||||
@unittest.skipUnless(hasattr(socket, "AF_UNIX"), "Unix sockets required")
|
||||
class UnixSocketHandlerTest(SocketHandlerTest):
|
||||
|
@ -1845,13 +1839,10 @@ class UnixSocketHandlerTest(SocketHandlerTest):
|
|||
|
||||
def setUp(self):
|
||||
# override the definition in the base class
|
||||
self.address = _get_temp_domain_socket()
|
||||
self.address = socket_helper.create_unix_domain_name()
|
||||
self.addCleanup(os_helper.unlink, self.address)
|
||||
SocketHandlerTest.setUp(self)
|
||||
|
||||
def tearDown(self):
|
||||
SocketHandlerTest.tearDown(self)
|
||||
os_helper.unlink(self.address)
|
||||
|
||||
@support.requires_working_socket()
|
||||
@threading_helper.requires_working_threading()
|
||||
class DatagramHandlerTest(BaseTest):
|
||||
|
@ -1928,13 +1919,10 @@ class UnixDatagramHandlerTest(DatagramHandlerTest):
|
|||
|
||||
def setUp(self):
|
||||
# override the definition in the base class
|
||||
self.address = _get_temp_domain_socket()
|
||||
self.address = socket_helper.create_unix_domain_name()
|
||||
self.addCleanup(os_helper.unlink, self.address)
|
||||
DatagramHandlerTest.setUp(self)
|
||||
|
||||
def tearDown(self):
|
||||
DatagramHandlerTest.tearDown(self)
|
||||
os_helper.unlink(self.address)
|
||||
|
||||
@support.requires_working_socket()
|
||||
@threading_helper.requires_working_threading()
|
||||
class SysLogHandlerTest(BaseTest):
|
||||
|
@ -2022,13 +2010,10 @@ class UnixSysLogHandlerTest(SysLogHandlerTest):
|
|||
|
||||
def setUp(self):
|
||||
# override the definition in the base class
|
||||
self.address = _get_temp_domain_socket()
|
||||
self.address = socket_helper.create_unix_domain_name()
|
||||
self.addCleanup(os_helper.unlink, self.address)
|
||||
SysLogHandlerTest.setUp(self)
|
||||
|
||||
def tearDown(self):
|
||||
SysLogHandlerTest.tearDown(self)
|
||||
os_helper.unlink(self.address)
|
||||
|
||||
@unittest.skipUnless(socket_helper.IPV6_ENABLED,
|
||||
'IPv6 support required for this test.')
|
||||
class IPv6SysLogHandlerTest(SysLogHandlerTest):
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue