-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Take column into account in functional tests #4013
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Take column into account in functional tests #4013
Conversation
d63c7b8
to
fcbe53b
Compare
fcbe53b
to
294662c
Compare
This is more complicated than I thought. I need to find a way to make it work on python 3.8 and 3.9 at least. Apparently the column change a lot between 3.5, 3.6, 3.7 and 3.8. |
@Pierre-Sassoulas at first sight it is a nice improvment! 👍 |
6d616d0
to
12dfca5
Compare
Before that an error while reading the file would make the update fail
12dfca5
to
9acbc05
Compare
8e840f0
to
e782c58
Compare
64d2854
to
f6557a5
Compare
@hippo91 I think this is ready to review. I wanted to wait for #3965 to be ready but the fix for python 3.5 were not that hard to make. (I don't understand how the tests are launched in python 3.5 as some typing prevent to launch them on my side, but anyway... I digress). The real column is not taken into account until python 3.8 because the AST changed at this point sp the value do not make as much sense before 3.8. |
@hippo91 I think we should merge this soon because it will cause a conflict on each functional test we need to rebase it on, so the less time in review the better. |
@Pierre-Sassoulas i already started the review. I ll try to finish it today. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Pierre-Sassoulas great work! 🎆 👍
I left just a few comments but nothing that prevent a merge in master!
def _get_expected(self): | ||
with self._open_source_file() as f: | ||
expected_msgs = self.get_expected_messages(f) | ||
return expected_msgs, [] | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I do not find the call place of this method...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
l.72 and l.106 in tests/test_func.py
and l. 167 in pylint/testutils/lint_module_test.py
:)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually the instance is initialized here:
@pytest.mark.parametrize("test_file", TESTS, ids=TESTS_NAMES)
def test_functional(test_file, recwarn):
if UPDATE_FILE.exists():
lint_test = LintModuleOutputUpdate(test_file)
else:
lint_test = testutils.LintModuleTest(test_file)
If we're using the update we instantiate a LintModuleOutputUpdate
that will be using this function later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Pierre-Sassoulas i'm sorry but i don't get it.
It seems to me that in tests/test_func.py
l.72 and l.106 it calls the method defined in the same module at line 93.
The call at l167 in lint_module_test.py
seems to be related to the method defined at line 140 of the same module.
I'm i wrong?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Regarding the call line 167 in lint_module_test.py
It the update file exists we instantiate a child class LintModuleOutputUpdate
of the mother class LintModuleTest
(code in comment above, from test_functional.py). Then when reaching _get_expected
l167 what is called is not the one defined l140 in LintModuleTest the but the one we're talking about overidden in the child class. Basically it comes done to this snippet with Mother=LintModuleTest and Child=LintModuleOutputUpdate:
class Mother:
def __init__(self):
print("Get expected is : {}".format(self._get_expected()))
def _get_expected(self):
return "Mother implementation."
class Child(Mother):
def _get_expected(self):
return "Child implementation."
Mother() # Get expected is : Mother implementation.
Child() # Get expected is : Child implementation.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok! Thanks @Pierre-Sassoulas
f001aaa
to
4df3747
Compare
Description
Surprisingly the column is not taken into account in functional test. This fix that and upgrade the expected result for functional test..
Type of Changes
Related Issue
#4003