Skip to content

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

Conversation

Pierre-Sassoulas
Copy link
Member

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

Type
✨ New feature

Related Issue

#4003

@coveralls
Copy link

coveralls commented Jan 3, 2021

Coverage Status

Coverage decreased (-0.03%) to 90.671% when pulling d170e17 on Pierre-Sassoulas:take-column-into-account-in-functional-tests into 168bee7 on PyCQA:master.

@Pierre-Sassoulas Pierre-Sassoulas force-pushed the take-column-into-account-in-functional-tests branch from fcbe53b to 294662c Compare January 3, 2021 22:30
@hippo91 hippo91 self-assigned this Jan 4, 2021
@Pierre-Sassoulas
Copy link
Member Author

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.

@hippo91
Copy link
Contributor

hippo91 commented Jan 4, 2021

@Pierre-Sassoulas at first sight it is a nice improvment! 👍
Let me know when you want me to have another look!

@Pierre-Sassoulas Pierre-Sassoulas force-pushed the take-column-into-account-in-functional-tests branch 2 times, most recently from 6d616d0 to 12dfca5 Compare January 17, 2021 15:56
@Pierre-Sassoulas Pierre-Sassoulas force-pushed the take-column-into-account-in-functional-tests branch from 12dfca5 to 9acbc05 Compare January 17, 2021 16:04
@Pierre-Sassoulas Pierre-Sassoulas force-pushed the take-column-into-account-in-functional-tests branch from 8e840f0 to e782c58 Compare January 18, 2021 08:29
@Pierre-Sassoulas Pierre-Sassoulas force-pushed the take-column-into-account-in-functional-tests branch from 64d2854 to f6557a5 Compare January 18, 2021 17:04
@Pierre-Sassoulas
Copy link
Member Author

@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.

@Pierre-Sassoulas
Copy link
Member Author

@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.

@hippo91
Copy link
Contributor

hippo91 commented Jan 23, 2021

@Pierre-Sassoulas i already started the review. I ll try to finish it today.

Copy link
Contributor

@hippo91 hippo91 left a 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!

Comment on lines +50 to +54
def _get_expected(self):
with self._open_source_file() as f:
expected_msgs = self.get_expected_messages(f)
return expected_msgs, []

Copy link
Contributor

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...

Copy link
Member Author

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 :)

Copy link
Member Author

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.

Copy link
Contributor

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?

Copy link
Member Author

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.   

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok! Thanks @Pierre-Sassoulas

@Pierre-Sassoulas Pierre-Sassoulas force-pushed the take-column-into-account-in-functional-tests branch from f001aaa to 4df3747 Compare January 23, 2021 14:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Enhancement ✨ Improvement to a component
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants