diff options
author | Claudiu Popa <pcmanticore@gmail.com> | 2018-04-04 21:10:26 +0200 |
---|---|---|
committer | Claudiu Popa <pcmanticore@gmail.com> | 2018-04-05 08:14:12 +0200 |
commit | fa8c99b6036872940639a047c081e675a399351a (patch) | |
tree | 1f574d75a9cf49d037901dfcd353f00a3ec7c575 | |
parent | d4c693700c6b9bb4332520473114b0b5d404b7fa (diff) | |
download | pylint-git-fa8c99b6036872940639a047c081e675a399351a.tar.gz |
Supress linting output
-rw-r--r-- | pylint/test/acceptance/test_stdlib.py | 29 |
1 files changed, 21 insertions, 8 deletions
diff --git a/pylint/test/acceptance/test_stdlib.py b/pylint/test/acceptance/test_stdlib.py index 71c278885..916f86415 100644 --- a/pylint/test/acceptance/test_stdlib.py +++ b/pylint/test/acceptance/test_stdlib.py @@ -1,8 +1,10 @@ # 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 +import contextlib +import io import os -import zipfile +import sys import pytest @@ -16,6 +18,16 @@ def is_module(filename): def is_package(filename, location): return os.path.exists(os.path.join(location, filename, '__init__.py')) + +@contextlib.contextmanager +def _patch_stdout(out): + sys.stdout = out + try: + yield + finally: + sys.stdout = sys.__stdout__ + + LIB_DIRS = [ os.path.dirname(os.__file__), os.path.dirname(zipfile.__file__) @@ -30,10 +42,11 @@ MODULES_NAMES = [m[1] for m in MODULES_TO_CHECK] MODULES_TO_CHECK, ids=MODULES_NAMES) def test_libmodule(test_module_location, test_module_name): os.chdir(test_module_location) - try: - pylint.lint.Run([test_module_name, '--enable=all']) - except SystemExit as ex: - assert ex.code != 32 - return - - assert False, "shouldn't get there" + with _patch_stdout(io.StringIO()): + try: + pylint.lint.Run([test_module_name, '--enable=all']) + except SystemExit as ex: + assert ex.code != 32 + return + + assert False, "shouldn't get there" |