[Python-checkins] cpython: Issue #17384: Consolidated cleanup operations in tests.
vinay.sajip
python-checkins at python.org
Fri Mar 8 10:51:32 CET 2013
http://hg.python.org/cpython/rev/85325bce9982
changeset: 82543:85325bce9982
user: Vinay Sajip <vinay_sajip at yahoo.co.uk>
date: Fri Mar 08 09:50:57 2013 +0000
summary:
Issue #17384: Consolidated cleanup operations in tests.
files:
Lib/test/test_logging.py | 18 ++++++++++++++----
1 files changed, 14 insertions(+), 4 deletions(-)
diff --git a/Lib/test/test_logging.py b/Lib/test/test_logging.py
--- a/Lib/test/test_logging.py
+++ b/Lib/test/test_logging.py
@@ -3396,6 +3396,12 @@
self.assertEqual(logging.root.level, self.original_logging_level)
def test_filename(self):
+
+ def cleanup(h1, h2, fn):
+ h1.close()
+ h2.close()
+ os.remove(fn)
+
logging.basicConfig(filename='test.log')
self.assertEqual(len(logging.root.handlers), 1)
@@ -3403,19 +3409,23 @@
self.assertIsInstance(handler, logging.FileHandler)
expected = logging.FileHandler('test.log', 'a')
- self.addCleanup(expected.close)
self.assertEqual(handler.stream.mode, expected.stream.mode)
self.assertEqual(handler.stream.name, expected.stream.name)
- self.addCleanup(os.remove, 'test.log')
+ self.addCleanup(cleanup, handler, expected, 'test.log')
def test_filemode(self):
+
+ def cleanup(h1, h2, fn):
+ h1.close()
+ h2.close()
+ os.remove(fn)
+
logging.basicConfig(filename='test.log', filemode='wb')
handler = logging.root.handlers[0]
expected = logging.FileHandler('test.log', 'wb')
- self.addCleanup(expected.close)
self.assertEqual(handler.stream.mode, expected.stream.mode)
- self.addCleanup(os.remove, 'test.log')
+ self.addCleanup(cleanup, handler, expected, 'test.log')
def test_stream(self):
stream = io.StringIO()
--
Repository URL: http://hg.python.org/cpython
More information about the Python-checkins
mailing list