Add explicit test that user can configure their own handler

pull/17064/head
Richard Belleville 6 years ago
parent fec37654fb
commit 78eae493b4
  1. 12
      src/python/grpcio_tests/tests/unit/_logging_test.py

@ -45,13 +45,23 @@ class LoggingTest(unittest.TestCase):
def test_handler_found(self):
try:
reload_module(logging)
logging.basicConfig()
reload_module(grpc)
self.assertFalse(
"No handlers could be found" in sys.stderr.getvalue())
finally:
reload_module(logging)
def test_can_configure_logger(self):
reload_module(logging)
reload_module(grpc)
try:
intended_stream = six.StringIO()
logging.basicConfig(stream=intended_stream)
self.assertEqual(1, len(logging.getLogger().handlers))
self.assertTrue(logging.getLogger().handlers[0].stream is intended_stream)
finally:
reload_module(logging)
if __name__ == '__main__':
unittest.main(verbosity=2)

Loading…
Cancel
Save