diff options
author | Richard Belleville <rbellevi@google.com> | 2018-10-31 16:43:36 -0700 |
---|---|---|
committer | Richard Belleville <rbellevi@google.com> | 2018-10-31 16:43:36 -0700 |
commit | b7335f5c011d9fad3570a097fb1165cc6fbd3cef (patch) | |
tree | 7148930cd493931387e2545863b03e17352ba776 /src/python/grpcio_tests/tests/unit/_logging_test.py | |
parent | a3ffca14403c6dd6d0678719cbfc06da1471769f (diff) |
Add test for 'No handlers could be found' problem
Diffstat (limited to 'src/python/grpcio_tests/tests/unit/_logging_test.py')
-rw-r--r-- | src/python/grpcio_tests/tests/unit/_logging_test.py | 17 |
1 files changed, 15 insertions, 2 deletions
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) |