Skip to content

Commit fb29593

Browse files
Uniformize message for failing legacy functional tests
1 parent 1ff39e9 commit fb29593

File tree

2 files changed

+20
-9
lines changed

2 files changed

+20
-9
lines changed

doc/development_guide/contribute.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -162,12 +162,14 @@ During development, it's sometimes helpful to run all functional tests in your
162162
current environment in order to have faster feedback. Run from Pylint root directory with::
163163

164164
python tests/test_functional.py
165+
python tests/test_func.py # For legacy functional tests
165166

166167
You can use all the options you would use for pytest, for example `-k "test_functional[len_checks]"`.
167168
It is also possible to update the expected output instead of using it for comparison, by appending
168169
`--update-functional-output` to the command line::
169170

170171
python tests/test_functional.py --update-functional-output -k "test_functional[len_checks]"
172+
python tests/test_func.py --update-functional-output # For legacy functional tests
171173

172174
.. _`Closing issues via commit messages`: https://help.github.com/articles/closing-issues-via-commit-messages/
173175
.. _`About pull requests`: https://help.github.com/articles/using-pull-requests/

tests/test_func.py

Lines changed: 18 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,15 @@ def _test_functionality(self):
6161
self._test(tocheck)
6262

6363
def _check_result(self, got):
64-
assert self._get_expected().strip() + "\n" == got.strip() + "\n"
64+
error_msg = (
65+
"Wrong output for '{_file}':\n"
66+
"You can update the expected output automatically with: '"
67+
"python tests/test_func.py {update_option}'\n\n".format(
68+
update_option=UPDATE_OPTION,
69+
_file=self.output,
70+
)
71+
)
72+
assert self._get_expected() == got, error_msg
6573

6674
def _test(self, tocheck):
6775
if INFO_TEST_RGX.match(self.module):
@@ -92,14 +100,15 @@ def _get_expected(self):
92100

93101
class LintTestUpdate(LintTestUsingModule):
94102
def _check_result(self, got):
95-
if self._has_output():
96-
try:
97-
expected = self._get_expected()
98-
except OSError:
99-
expected = ""
100-
if got != expected:
101-
with open(self.output, "w") as fobj:
102-
fobj.write(got)
103+
if not self._has_output():
104+
return
105+
try:
106+
expected = self._get_expected()
107+
except OSError:
108+
expected = ""
109+
if got != expected:
110+
with open(self.output, "w") as f:
111+
f.write(got)
103112

104113

105114
def gen_tests(filter_rgx):

0 commit comments

Comments
 (0)