-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Refactor functional testutil in order to normalize later #5418
Refactor functional testutil in order to normalize later #5418
Conversation
51fc083
to
9b8ea92
Compare
Pull Request Test Coverage Report for Build 1515867452
π - Coveralls |
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 think we need to add some additional tests for the DeprecationWarning
's to make sure this isn't breaking. We have been doing that for other DeprecationWarning
's as well.
Think this is a good move to make!
|
||
import pytest | ||
|
||
from pylint.testutils import FunctionalTestFile |
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.
Shall we add an test to see if the deprecation warning triggers correctly when doing this import?
I think it might be better to add this in a with pytest.warns
guard anyway as we will otherwise always trigger the warning ourselves.
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'd like to do that but I don't know what is triggering the deprecation warning, it's supposed to not ever be imported.
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.
What happens if somebody uses the current way to import it? Doesn't that trigger the deprecation?
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.
Well there's a warning when we launch the test at the beginning not when we re-import later in the test:
with pytest.warns(DeprecationWarning) as records:
from pylint.testutils.functional_test_file import FunctionalTestFile
Result in :
with pytest.warns(DeprecationWarning) as records:
> from pylint.testutils.functional_test_file import FunctionalTestFile
E Failed: DID NOT WARN. No warnings of type (<class 'DeprecationWarning'>,) was emitted. The list of emitted warnings is: [].
tests/testutils/test_functional_test_file.py:5: Failed
============================================================================================ warnings summary =============================================================================================
pylint/testutils/functional_test_file.py:18
/home/pierre/pylint/pylint/testutils/functional_test_file.py:18: DeprecationWarning: 'pylint.testutils.functional_test_file' will be accessible from the 'pylint.testutils.functional' namespace in pylint 3.0.
Notice how the deprecation Warning is taunting us at the bottom π
Somehow there must be an import from this file that I can't seem to find.
I'm inclined to revert the typing here and keep it for another MR as the following error appear:
|
Could you try to see if this works? if sys.version_info >= (3, 8):
from typing import TypedDict
else:
from typing_extensions import TypedDict
class TestFileOptions(TypedDict):
min_pyver: Tuple[int, ...]
max_pyver: Tuple[int, ...]
min_pyver_end_position: Tuple[int, ...]
requires: List[str]
except_implementations: List[str]
exclude_platforms: List[str]
...
self.options: TestFileOptions = { I think that should do it? If not reverting might indeed be best π’ |
Thanks, done in df20ded. It's too big for this MR but I started to cherry-pick on main and there's conflicts... so let's merge everything here. |
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.
Looks good! We actually caught some "bugs" due to the typing π
conv = self._CONVERTERS.get(name, lambda v: v) | ||
|
||
assert ( | ||
name in POSSIBLE_TEST_OPTIONS |
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.
TestFileOptions.__annotations__
would also work, but I'm not sure if you're supposed to access it..
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 don't like typed dict, it's only marginally better than a dict. Might refactor that class later.
And use Path instead of os
Better typing for test options and fix existing issue
8135de0
to
a2a66a6
Compare
Why is this MR blocked? |
Waiting for 2.12.2 to be released : #5418 (comment) |
Type of Changes
Description
The functional tests grow all the time and organizing them properly will become a problem soon. See possible follow up here: #5396 (comment)