summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_logging.py
diff options
context:
space:
mode:
authorVictor Stinner <vstinner@python.org>2022-06-17 11:16:51 (GMT)
committerGitHub <noreply@github.com>2022-06-17 11:16:51 (GMT)
commitc5b750dc0b4d4e58047c9d93c635fa26b06562f7 (patch)
treea3a1701db431c87b54036b0f890dcf5c4a4230dd /Lib/test/test_logging.py
parentffc228dd4e409336f2c2ad54125de384bf1a767b (diff)
downloadcpython-c5b750dc0b4d4e58047c9d93c635fa26b06562f7.zip
cpython-c5b750dc0b4d4e58047c9d93c635fa26b06562f7.tar.gz
cpython-c5b750dc0b4d4e58047c9d93c635fa26b06562f7.tar.bz2
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.
Diffstat (limited to 'Lib/test/test_logging.py')
-rw-r--r--Lib/test/test_logging.py27
1 files changed, 6 insertions, 21 deletions
diff --git a/Lib/test/test_logging.py b/Lib/test/test_logging.py
index f4a4324..7859c60 100644
--- a/Lib/test/test_logging.py
+++ b/Lib/test/test_logging.py
@@ -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):