Skip to content

Check node location attributes in unittests #5383

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

Merged
merged 12 commits into from
Dec 13, 2021

Conversation

DanielNoord
Copy link
Collaborator

@DanielNoord DanielNoord commented Nov 24, 2021

  • Add yourself to CONTRIBUTORS if you are a new contributor.
  • Add a ChangeLog entry describing what your PR does.
  • If it's a new feature, or an important bug fix, add a What's New entry in
    doc/whatsnew/<current release.rst>.
  • Write a good description on what the PR does.

Type of Changes

Type
🐛 Bug fix
✨ New feature
🔨 Refactoring

Description

List of unittests which "can't" be moved and are updated to now include location attributes:

  • TestMultiNamingStyle

@DanielNoord DanielNoord added Enhancement ✨ Improvement to a component Maintenance Discussion or action around maintaining pylint or the dev workflow labels Nov 24, 2021
@Pierre-Sassoulas
Copy link
Member

This will be a nightmare to review...

To be fair this is probably a nightmare to write too. How about we move most of this to the functional tests ? It's more understandable for contributor and a lot easier to maintain for us. Because a functional test would be reviewable with vscode + pylint (modulo finding a way to use a dev version in vscode) by opening the file and looking at the column displayed, right ?

@DanielNoord
Copy link
Collaborator Author

This will be a nightmare to review...

To be fair this is probably a nightmare to write too. How about we move most of this to the functional tests ? It's more understandable for contributor and a lot easier to maintain for us. Because a functional test would be reviewable with vscode + pylint (modulo finding a way to use a dev version in vscode) by opening the file and looking at the column displayed, right ?

Not sure if converting to functional tests will take less time though.. I have never done it, did it take you much time last time?

@Pierre-Sassoulas
Copy link
Member

did it take you much time last time?

Well it's relatively fast, you copy paste code and then add the expected message where required (# [missing-docstring]) or remove unwanted message. But it will take longer if the file does not exist yet I guess. Not making a mess and organizing the functional test properly will become important if we massively move unittest to functional though.

@DanielNoord
Copy link
Collaborator Author

I'll start working on it then. Keeping this PR open to track the progress on it so we know when the unittests are "testing" end_line.

@Pierre-Sassoulas Pierre-Sassoulas added this to the 2.13.0 milestone Nov 28, 2021
@DanielNoord
Copy link
Collaborator Author

We're under 100 failed tests on 3.10 now 😄

@DanielNoord DanielNoord force-pushed the unittests branch 3 times, most recently from e759298 to 8aabbfb Compare December 8, 2021 18:43
@Pierre-Sassoulas
Copy link
Member

Only 36 tests left 🎉 but it look like the functional tests needs updating and there would be less than that.

@DanielNoord DanielNoord marked this pull request as ready for review December 13, 2021 15:20
@DanielNoord
Copy link
Collaborator Author

Finally ready for review!

Copy link
Member

@Pierre-Sassoulas Pierre-Sassoulas left a comment

Choose a reason for hiding this comment

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

There's still a surprisingly big number of tests that can"t be moved to functional, but this became clearly more manageable, I'm glad we won't have to change the line/col manually for the migrated tests. Amazing work you did there !

@@ -30,6 +30,8 @@ def add_message(
self,
msg_id: str,
line: Optional[int] = None,
# pylint: disable=fixme
# TODO: Make node non optional
Copy link
Member

Choose a reason for hiding this comment

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

👍

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Turns out this is actually because node is optional in pylint itself 😅
I guess we can add that to our mental todo list for 3.0

Copy link
Member

Choose a reason for hiding this comment

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

Yeap, that's probably some work too :)

@DanielNoord
Copy link
Collaborator Author

There's still a surprisingly big number of tests that can"t be moved to functional

For some of the remaining tests it was simply just better to keep them as is. Some used parameterization or imported additional data which would be difficult to replicate in functional tests.

@Pierre-Sassoulas
Copy link
Member

Some used parameterization

I think unittest works really well with parametrization when applicable. How about adding a little doc about tests : Prefer functional tests, unless there are a lot of similar cases that can be parametrized, or if you're using additional data ?

@coveralls
Copy link

coveralls commented Dec 13, 2021

Pull Request Test Coverage Report for Build 1573560118

  • 26 of 28 (92.86%) changed or added relevant lines in 3 files are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage decreased (-0.003%) to 93.652%

Changes Missing Coverage Covered Lines Changed/Added Lines %
pylint/testutils/checker_test_case.py 16 18 88.89%
Totals Coverage Status
Change from base Build 1573470747: -0.003%
Covered Lines: 14206
Relevant Lines: 15169

💛 - Coveralls

@DanielNoord
Copy link
Collaborator Author

Some used parameterization

I think unittest works really well with parametrization when applicable. How about adding a little doc about tests : Prefer functional tests, unless there are a lot of similar cases that can be parametrized, or if you're using additional data ?

I don't think we should give people reasons to write more unittests, they will probably already do so since it is the most common way of testing.
There are so many difficulties with config parsing, loading of checkers etc that we should really prefer functional test unless truly impossible.

@DanielNoord DanielNoord merged commit 71bbbdb into pylint-dev:main Dec 13, 2021
@DanielNoord DanielNoord deleted the unittests branch December 13, 2021 22:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Enhancement ✨ Improvement to a component Maintenance Discussion or action around maintaining pylint or the dev workflow
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants