diff options
author | Vinay Sajip <vinay_sajip@yahoo.co.uk> | 2013-09-27 17:41:12 (GMT) |
---|---|---|
committer | Vinay Sajip <vinay_sajip@yahoo.co.uk> | 2013-09-27 17:41:12 (GMT) |
commit | f6cdffeb789f043bc47ae9c172891a13860e1b21 (patch) | |
tree | 0baf9c08c825a401ce37ca2545e1a75ab97eb312 /Lib/test/test_logging.py | |
parent | 5421f35d5e215a69382f0c195c0c39c8b541eca7 (diff) | |
download | cpython-f6cdffeb789f043bc47ae9c172891a13860e1b21.zip cpython-f6cdffeb789f043bc47ae9c172891a13860e1b21.tar.gz cpython-f6cdffeb789f043bc47ae9c172891a13860e1b21.tar.bz2 |
Streamlined logging tests by moving common code to a helper function.
Diffstat (limited to 'Lib/test/test_logging.py')
-rw-r--r-- | Lib/test/test_logging.py | 26 |
1 files changed, 10 insertions, 16 deletions
diff --git a/Lib/test/test_logging.py b/Lib/test/test_logging.py index cbdc78c..fc7411d 100644 --- a/Lib/test/test_logging.py +++ b/Lib/test/test_logging.py @@ -1437,6 +1437,13 @@ class SocketHandlerTest(BaseTest): time.sleep(self.sock_hdlr.retryTime - now + 0.001) 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.') class UnixSocketHandlerTest(SocketHandlerTest): @@ -1447,10 +1454,7 @@ class UnixSocketHandlerTest(SocketHandlerTest): def setUp(self): # override the definition in the base class - fd, self.address = tempfile.mkstemp(prefix='test_logging_', - suffix='.sock') - os.close(fd) - os.remove(self.address) # just need a name - file can't be present + self.address = _get_temp_domain_socket() SocketHandlerTest.setUp(self) def tearDown(self): @@ -1520,10 +1524,7 @@ class UnixDatagramHandlerTest(DatagramHandlerTest): def setUp(self): # override the definition in the base class - fd, self.address = tempfile.mkstemp(prefix='test_logging_', - suffix='.sock') - os.close(fd) - os.remove(self.address) # just need a name - file can't be present + self.address = _get_temp_domain_socket() DatagramHandlerTest.setUp(self) def tearDown(self): @@ -1596,20 +1597,13 @@ class UnixSysLogHandlerTest(SysLogHandlerTest): def setUp(self): # override the definition in the base class - fd, self.address = tempfile.mkstemp(prefix='test_logging_', - suffix='.sock') - os.close(fd) - os.remove(self.address) # just need a name - file can't be present + self.address = _get_temp_domain_socket() SysLogHandlerTest.setUp(self) def tearDown(self): SysLogHandlerTest.tearDown(self) 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.') class HTTPHandlerTest(BaseTest): """Test for HTTPHandler.""" |