summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorPierre Sassoulas <pierre.sassoulas@gmail.com>2021-01-01 15:56:15 +0100
committerPierre Sassoulas <pierre.sassoulas@gmail.com>2021-01-01 16:42:28 +0100
commit00868cb9df8119da054e7f1d37be3e474e5e6b77 (patch)
tree0b5ee8d62833f393b108d6cd500e0d692b5d1c24 /tests
parentd3fd372248aeab4105186d4af4e5b12176af40f4 (diff)
downloadpylint-git-00868cb9df8119da054e7f1d37be3e474e5e6b77.tar.gz
Uniformize update mechanism in functional tests
Diffstat (limited to 'tests')
-rw-r--r--tests/test_func.py27
1 files changed, 18 insertions, 9 deletions
diff --git a/tests/test_func.py b/tests/test_func.py
index 1508c5585..2f6231f87 100644
--- a/tests/test_func.py
+++ b/tests/test_func.py
@@ -61,7 +61,15 @@ class LintTestUsingModule:
self._test(tocheck)
def _check_result(self, got):
- assert self._get_expected().strip() + "\n" == got.strip() + "\n"
+ error_msg = (
+ "Wrong output for '{_file}':\n"
+ "You can update the expected output automatically with: '"
+ "python tests/test_func.py {update_option}'\n\n".format(
+ update_option=UPDATE_OPTION,
+ _file=self.output,
+ )
+ )
+ assert self._get_expected() == got, error_msg
def _test(self, tocheck):
if INFO_TEST_RGX.match(self.module):
@@ -92,14 +100,15 @@ class LintTestUsingModule:
class LintTestUpdate(LintTestUsingModule):
def _check_result(self, got):
- if self._has_output():
- try:
- expected = self._get_expected()
- except OSError:
- expected = ""
- if got != expected:
- with open(self.output, "w") as fobj:
- fobj.write(got)
+ if not self._has_output():
+ return
+ try:
+ expected = self._get_expected()
+ except OSError:
+ expected = ""
+ if got != expected:
+ with open(self.output, "w") as f:
+ f.write(got)
def gen_tests(filter_rgx):