mirror of https://github.com/python/cpython
Streamlined logging tests by moving common code to a helper function.
This commit is contained in:
parent
5421f35d5e
commit
f6cdffeb78
|
@ -1437,6 +1437,13 @@ class SocketHandlerTest(BaseTest):
|
||||||
time.sleep(self.sock_hdlr.retryTime - now + 0.001)
|
time.sleep(self.sock_hdlr.retryTime - now + 0.001)
|
||||||
self.root_logger.error('Nor this')
|
self.root_logger.error('Nor this')
|
||||||
|
|
||||||
|
def _get_temp_domain_socket():
|
||||||
|
fd, fn = tempfile.mkstemp(prefix='test_logging_', suffix='.sock')
|
||||||
|
os.close(fd)
|
||||||
|
# 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(threading, 'Threading required for this test.')
|
@unittest.skipUnless(threading, 'Threading required for this test.')
|
||||||
class UnixSocketHandlerTest(SocketHandlerTest):
|
class UnixSocketHandlerTest(SocketHandlerTest):
|
||||||
|
@ -1447,10 +1454,7 @@ class UnixSocketHandlerTest(SocketHandlerTest):
|
||||||
|
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
# override the definition in the base class
|
# override the definition in the base class
|
||||||
fd, self.address = tempfile.mkstemp(prefix='test_logging_',
|
self.address = _get_temp_domain_socket()
|
||||||
suffix='.sock')
|
|
||||||
os.close(fd)
|
|
||||||
os.remove(self.address) # just need a name - file can't be present
|
|
||||||
SocketHandlerTest.setUp(self)
|
SocketHandlerTest.setUp(self)
|
||||||
|
|
||||||
def tearDown(self):
|
def tearDown(self):
|
||||||
|
@ -1520,10 +1524,7 @@ class UnixDatagramHandlerTest(DatagramHandlerTest):
|
||||||
|
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
# override the definition in the base class
|
# override the definition in the base class
|
||||||
fd, self.address = tempfile.mkstemp(prefix='test_logging_',
|
self.address = _get_temp_domain_socket()
|
||||||
suffix='.sock')
|
|
||||||
os.close(fd)
|
|
||||||
os.remove(self.address) # just need a name - file can't be present
|
|
||||||
DatagramHandlerTest.setUp(self)
|
DatagramHandlerTest.setUp(self)
|
||||||
|
|
||||||
def tearDown(self):
|
def tearDown(self):
|
||||||
|
@ -1596,20 +1597,13 @@ class UnixSysLogHandlerTest(SysLogHandlerTest):
|
||||||
|
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
# override the definition in the base class
|
# override the definition in the base class
|
||||||
fd, self.address = tempfile.mkstemp(prefix='test_logging_',
|
self.address = _get_temp_domain_socket()
|
||||||
suffix='.sock')
|
|
||||||
os.close(fd)
|
|
||||||
os.remove(self.address) # just need a name - file can't be present
|
|
||||||
SysLogHandlerTest.setUp(self)
|
SysLogHandlerTest.setUp(self)
|
||||||
|
|
||||||
def tearDown(self):
|
def tearDown(self):
|
||||||
SysLogHandlerTest.tearDown(self)
|
SysLogHandlerTest.tearDown(self)
|
||||||
os.remove(self.address)
|
os.remove(self.address)
|
||||||
|
|
||||||
# def test_output(self):
|
|
||||||
# import pdb; pdb.set_trace()
|
|
||||||
# SysLogHandlerTest.test_output(self)
|
|
||||||
|
|
||||||
@unittest.skipUnless(threading, 'Threading required for this test.')
|
@unittest.skipUnless(threading, 'Threading required for this test.')
|
||||||
class HTTPHandlerTest(BaseTest):
|
class HTTPHandlerTest(BaseTest):
|
||||||
"""Test for HTTPHandler."""
|
"""Test for HTTPHandler."""
|
||||||
|
|
Loading…
Reference in New Issue