summaryrefslogtreecommitdiffstats
path: root/Lib/test
diff options
context:
space:
mode:
authorVinay Sajip <vinay_sajip@yahoo.co.uk>2017-07-30 09:41:45 (GMT)
committerGitHub <noreply@github.com>2017-07-30 09:41:45 (GMT)
commit2543f50033208c1a8df04999082b11aa09e82a04 (patch)
treeb74c99e4821404d6dfdc4d0076e0810690bcff73 /Lib/test
parent78c18a9b9a1445f7c755929917a790ba02b4a5e0 (diff)
downloadcpython-2543f50033208c1a8df04999082b11aa09e82a04.zip
cpython-2543f50033208c1a8df04999082b11aa09e82a04.tar.gz
cpython-2543f50033208c1a8df04999082b11aa09e82a04.tar.bz2
bpo-30522: Implemented a method to allow setting a logging.StreamHander's stream. (GH-2921)
Diffstat (limited to 'Lib/test')
-rw-r--r--Lib/test/test_logging.py14
1 files changed, 14 insertions, 0 deletions
diff --git a/Lib/test/test_logging.py b/Lib/test/test_logging.py
index 8884562..6d0b234 100644
--- a/Lib/test/test_logging.py
+++ b/Lib/test/test_logging.py
@@ -698,6 +698,20 @@ class StreamHandlerTest(BaseTest):
finally:
logging.raiseExceptions = old_raise
+ def test_stream_setting(self):
+ """
+ Test setting the handler's stream
+ """
+ h = logging.StreamHandler()
+ stream = io.StringIO()
+ old = h.setStream(stream)
+ self.assertIs(old, sys.stderr)
+ actual = h.setStream(old)
+ self.assertIs(actual, stream)
+ # test that setting to existing value returns None
+ actual = h.setStream(old)
+ self.assertIsNone(actual)
+
# -- The following section could be moved into a server_helper.py module
# -- if it proves to be of wider utility than just test_logging