summaryrefslogtreecommitdiff
path: root/pylint/test/unittest_lint.py
diff options
context:
space:
mode:
authorScott Worley <scottworley@scottworley.com>2018-08-21 13:21:52 -0700
committerClaudiu Popa <pcmanticore@gmail.com>2018-08-22 08:23:34 +0200
commit49f47b5b2a32b13d9b0dfef8de82b1510a3ae28d (patch)
treeea036819140afba281d8f5243d7dc339e65bcc80 /pylint/test/unittest_lint.py
parent15336694542664b4d8eff61afc607cfbb4c0054d (diff)
downloadpylint-git-49f47b5b2a32b13d9b0dfef8de82b1510a3ae28d.tar.gz
Use contextlib.redirect_stdout
Diffstat (limited to 'pylint/test/unittest_lint.py')
-rw-r--r--pylint/test/unittest_lint.py11
1 files changed, 4 insertions, 7 deletions
diff --git a/pylint/test/unittest_lint.py b/pylint/test/unittest_lint.py
index ae92446b4..ceccbf65b 100644
--- a/pylint/test/unittest_lint.py
+++ b/pylint/test/unittest_lint.py
@@ -26,7 +26,7 @@
# Licensed under the GPL: https://www.gnu.org/licenses/old-licenses/gpl-2.0.html
# For details: https://github.com/PyCQA/pylint/blob/master/COPYING
-from contextlib import contextmanager
+from contextlib import contextmanager, redirect_stdout
import sys
import os
import re
@@ -702,14 +702,11 @@ class TestMessagesStore(object):
msg, checkerref=False)
def test_list_messages(self, store):
- sys.stdout = StringIO()
- try:
+ output = StringIO()
+ with redirect_stdout(output):
store.list_messages()
- output = sys.stdout.getvalue()
- finally:
- sys.stdout = sys.__stdout__
# cursory examination of the output: we're mostly testing it completes
- assert ':msg-symbol (W1234): *message*' in output
+ assert ':msg-symbol (W1234): *message*' in output.getvalue()
def test_add_renamed_message(self, store):
store.add_renamed_message('W1234', 'old-bad-name', 'msg-symbol')