diff options
author | Richard Belleville <rbellevi@google.com> | 2018-10-31 17:20:43 -0700 |
---|---|---|
committer | Richard Belleville <rbellevi@google.com> | 2018-10-31 17:20:43 -0700 |
commit | 78eae493b45828372dd8409b53ab5479ac39b248 (patch) | |
tree | ae3b973976bfe30aa963b35d997593733f16fe62 | |
parent | fec37654fb59865c6d602575a9955a5545e94520 (diff) |
Add explicit test that user can configure their own handler
-rw-r--r-- | src/python/grpcio_tests/tests/unit/_logging_test.py | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/src/python/grpcio_tests/tests/unit/_logging_test.py b/src/python/grpcio_tests/tests/unit/_logging_test.py index d378d466b3..e409a24637 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) |