From: Ben Darnell Date: Mon, 6 Jan 2014 23:49:33 +0000 (-0500) Subject: Remove inaccurate IOLoop logging test cases. X-Git-Tag: v3.2.0b2~6 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=daab25b994ff115dc525b546980c418bb9f2e125;p=thirdparty%2Ftornado.git Remove inaccurate IOLoop logging test cases. --- diff --git a/tornado/test/ioloop_test.py b/tornado/test/ioloop_test.py index daa1beab5..fa863e611 100644 --- a/tornado/test/ioloop_test.py +++ b/tornado/test/ioloop_test.py @@ -12,7 +12,7 @@ import threading import time from tornado import gen -from tornado.ioloop import IOLoop, TimeoutError +from tornado.ioloop import IOLoop, PollIOLoop, TimeoutError from tornado.stack_context import ExceptionStackContext, StackContext, wrap, NullContext from tornado.testing import AsyncTestCase, bind_unused_port from tornado.test.util import unittest, skipIfNonUnix, skipOnTravis @@ -22,14 +22,6 @@ try: except ImportError: futures = None -try: - from unittest import mock # python 3.3+ -except ImportError: - try: - import mock # third-party mock package - except ImportError: - mock = None - class TestIOLoop(AsyncTestCase): @skipOnTravis @@ -339,43 +331,5 @@ class TestIOLoopRunSync(unittest.TestCase): self.assertRaises(TimeoutError, self.io_loop.run_sync, f, timeout=0.01) -class TestIOLoopLogging(AsyncTestCase): - - @unittest.skipIf(mock is None, 'mock package not present') - def test_basic_config_invoked(self): - """If no loggers have been defined, logging.basicConfig should be called - test for the presence of a root logger, start IOloop and then test - to see if one has been added - - """ - with mock.patch('logging.basicConfig') as basicConfig: - self.io_loop.add_timeout(datetime.timedelta(microseconds=1), - self.stop) - self.wait() - basicConfig.assert_called_once() - - @unittest.skipIf(mock is None, 'mock package not present') - def test_basic_config_not_invoked(self): - """The setup_logging method will check for getLogger().handlers, - getLogger('tornado').handlers and - getLogger('tornado.application').handlers. If all are empty, it will - invoke basicConfig. Test to make sure all three are called, all three - are checked and basicConfig is not invoked because there is a handler - returned (for each). - - """ - with mock.patch('logging.getLogger') as getLogger: - with mock.patch('logging.basicConfig') as basicConfig: - getLogger.handlers = [True] - self.io_loop.add_timeout(datetime.timedelta(microseconds=1), - self.stop) - self.wait() - basicConfig.assert_not_called() - getLogger.assert_has_calls([mock.call(), - mock.call('tornado'), - mock.call('tornado.application')]) - self.assertEqual(getLogger.call_count, 3) - - if __name__ == "__main__": unittest.main()