From b7335f5c011d9fad3570a097fb1165cc6fbd3cef Mon Sep 17 00:00:00 2001 From: Richard Belleville Date: Wed, 31 Oct 2018 16:43:36 -0700 Subject: Add test for 'No handlers could be found' problem --- src/python/grpcio_tests/tests/unit/_logging_test.py | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) (limited to 'src/python') diff --git a/src/python/grpcio_tests/tests/unit/_logging_test.py b/src/python/grpcio_tests/tests/unit/_logging_test.py index 08163089de..662cd1ea9d 100644 --- a/src/python/grpcio_tests/tests/unit/_logging_test.py +++ b/src/python/grpcio_tests/tests/unit/_logging_test.py @@ -15,15 +15,28 @@ import unittest import six -import grpc +from six.moves import reload_module import logging - +import grpc +import functools +import sys class LoggingTest(unittest.TestCase): def test_logger_not_occupied(self): self.assertEqual(0, len(logging.getLogger().handlers)) + def test_handler_found(self): + old_stderr = sys.stderr + sys.stderr = six.StringIO() + try: + reload_module(logging) + logging.basicConfig() + reload_module(grpc) + self.assertFalse("No handlers could be found" in sys.stderr.getvalue()) + finally: + sys.stderr = old_stderr + reload_module(logging) if __name__ == '__main__': unittest.main(verbosity=2) -- cgit v1.2.3