diff --git a/src/python/grpcio_tests/tests/unit/_logging_test.py b/src/python/grpcio_tests/tests/unit/_logging_test.py index d378d466b3b..e409a246379 100644 --- a/src/python/grpcio_tests/tests/unit/_logging_test.py +++ b/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)