summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarc Mueller <30130371+cdce8p@users.noreply.github.com>2021-03-26 21:53:20 +0100
committerPierre Sassoulas <pierre.sassoulas@gmail.com>2021-03-28 22:48:56 +0200
commitc5ad01c4865fb20af90cff241f595e5fe06e37c2 (patch)
tree1b39a30bcdf11fccd86f6c6e41ad55fe7dd78b7e
parent9882eebf31b8242b14e1b99cf840debd87b07d19 (diff)
downloadpylint-git-c5ad01c4865fb20af90cff241f595e5fe06e37c2.tar.gz
Only print verbose logs if pytest -v
-rw-r--r--pylint/testutils/lint_module_test.py11
-rw-r--r--tests/test_functional.py6
2 files changed, 10 insertions, 7 deletions
diff --git a/pylint/testutils/lint_module_test.py b/pylint/testutils/lint_module_test.py
index 653a6dcdb..158e4f6a5 100644
--- a/pylint/testutils/lint_module_test.py
+++ b/pylint/testutils/lint_module_test.py
@@ -7,9 +7,10 @@ import platform
import sys
from collections import Counter
from io import StringIO
-from typing import Dict, List, Tuple
+from typing import Dict, List, Optional, Tuple
import pytest
+from _pytest.config import Config
from pylint import checkers
from pylint.lint import PyLinter
@@ -26,7 +27,7 @@ from pylint.testutils.reporter_for_tests import FunctionalTestReporter
class LintModuleTest:
maxDiff = None
- def __init__(self, test_file: FunctionalTestFile):
+ def __init__(self, test_file: FunctionalTestFile, config: Optional[Config] = None):
_test_reporter = FunctionalTestReporter()
self._linter = PyLinter()
self._linter.set_reporter(_test_reporter)
@@ -41,6 +42,7 @@ class LintModuleTest:
except NoFileError:
pass
self._test_file = test_file
+ self._config = config
def setUp(self):
if self._should_be_skipped_due_to_version():
@@ -187,8 +189,9 @@ class LintModuleTest:
msg.append("\nUnexpected in testdata:")
msg.extend(" %3d: %s" % msg for msg in sorted(unexpected)) # type: ignore
error_msg = "\n".join(msg)
- error_msg += "\n\nActual pylint output for this file:\n"
- error_msg += "\n".join(str(o) for o in actual_output)
+ if self._config and self._config.getoption("verbose") > 0:
+ error_msg += "\n\nActual pylint output for this file:\n"
+ error_msg += "\n".join(str(o) for o in actual_output)
return error_msg
def error_msg_for_unequal_output(self, expected_lines, received_lines) -> str:
diff --git a/tests/test_functional.py b/tests/test_functional.py
index 0d015f33e..18706f4f2 100644
--- a/tests/test_functional.py
+++ b/tests/test_functional.py
@@ -94,11 +94,11 @@ TEST_WITH_EXPECTED_DEPRECATION = [
@pytest.mark.parametrize("test_file", TESTS, ids=TESTS_NAMES)
-def test_functional(test_file, recwarn):
+def test_functional(test_file, recwarn, pytestconfig):
if UPDATE_FILE.exists():
- lint_test = LintModuleOutputUpdate(test_file)
+ lint_test = LintModuleOutputUpdate(test_file, pytestconfig)
else:
- lint_test = testutils.LintModuleTest(test_file)
+ lint_test = testutils.LintModuleTest(test_file, pytestconfig)
lint_test.setUp()
lint_test._runTest()
warning = None