-
Notifications
You must be signed in to change notification settings - Fork 273
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
Start linting the test #1710
Start linting the test #1710
Conversation
88601b3
to
6f5bd1b
Compare
Pull Request Test Coverage Report for Build 1559295338
💛 - 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.
Thanks for the PR, @MVrachev! Looks like a straight-forward set of changes. I left some minor suggestions, but will approve regardless.
I see you adopted the filename changes (add "_old" infix) in some doc headers but not all. I suggest to do this consistently and I'm fine with not updating the doc headers, given that these files are bound to be removed.
@@ -36,7 +36,6 @@ | |||
metadata without the client being aware. | |||
""" | |||
|
|||
import datetime |
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.
Why this change in an "_old.py" file?
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 just saw it was unused and decided to remove it, but I can return it if it looks strange.
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.
🤷 Probably not worth the effort. :) Let's leave it there.
@@ -117,6 +121,7 @@ def test_top_level_roles_update(self, test_case_data: Dict[str, Any]): | |||
sim = self._init_repo(consistent_snapshot) | |||
updater = self._init_updater(sim) | |||
|
|||
# pylint: disable=protected-access |
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.
Maybe we want to disable this globally for all tests?
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 think that is possible as of today.
See issue pylint-dev/pylint#618 and their project where they keep track of the progress on that issue https://github.com/PyCQA/pylint/projects/1
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 think that is possible as of today.
See issue pylint-dev/pylint#618 and their project where they keep track of the progress on that issue https://github.com/PyCQA/pylint/projects/1
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.
You could call pylint separately for tests and for everything else in tox.ini, as we do for in-toto.
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.
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.
globally disabling the lint is ok ... but at this point might be overkill: As an example, there's already a PR that removes these protected accesses (because there is a better design for these cases): I think we won't have more than a couple in the whole test suite next week.
(this is a response to earlier comment)
Just merged #1708. Please rebase and mark ready for review! |
a30a8e8
to
317b9d1
Compare
I rebased on top of develop and I think changed all the relevant doc headers and places where the file names of |
317b9d1
to
53a2599
Compare
I had to rebase to change the test name used as an example in |
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.
Moving almost obsolete files is a bit annoying but I can see why you want to flick the switch on this one :) style guidelines won't be observed without hard failures... LGTM in general
We should keep statically checking dateutil, otherwise my comments are just discussion.
@@ -117,6 +121,7 @@ def test_top_level_roles_update(self, test_case_data: Dict[str, Any]): | |||
sim = self._init_repo(consistent_snapshot) | |||
updater = self._init_updater(sim) | |||
|
|||
# pylint: disable=protected-access |
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.
globally disabling the lint is ok ... but at this point might be overkill: As an example, there's already a PR that removes these protected accesses (because there is a better design for these cases): I think we won't have more than a couple in the whole test suite next week.
(this is a response to earlier comment)
b0297b5
to
f0bf488
Compare
The changes are automatic linting fixes from black. The target files are only those who test the new code. Signed-off-by: Martin Vrachev <[email protected]>
All of the changes are made manual. The target files are only those who test the new code. Signed-off-by: Martin Vrachev <[email protected]>
All of the changes are made manual. The target files are only those who test the new code. Signed-off-by: Martin Vrachev <[email protected]>
Rename test files testing the old code by adding an "old" suffix. This is done, so we can easily exclude them from linting. Signed-off-by: Martin Vrachev <[email protected]>
Exclude regexs/globs are needed to exclude the test files testing the old code. After we remove those files we will be able to remove the exclude regex/globs. Signed-off-by: Martin Vrachev <[email protected]>
Mypy reported a couple of errors for missing stubs on GitHub https://github.com/theupdateframework/python-tuf/runs/4431787287?check_suite_focus=true The error noted that: "tests/test_api.py:19: error: Library stubs not installed for "dateutil.relativedelta" (or incompatible with Python 3.10)" In order to resolve it I added "types-python-dateutil" into requirements-test.txt Signed-off-by: Martin Vrachev <[email protected]>
Logging configuration is part from each test file begging from commit theupdateframework@03b15fb We should that as well for tests/test_examples.py Signed-off-by: Martin Vrachev <[email protected]>
Make _fetch_metadata and _fetch_taget public by renaming them to fetch_metadata and fetch_target. This will allow the removal of multiple pylint disables because of "accessing private members". Signed-off-by: Martin Vrachev <[email protected]>
Mypy warns us when we assign a not defined variable to an object, but that is something that we are warned for from pylint (seach for "pylint: disable=no-member" in test_updater_key_rotations.py and you will find an example where we have to disable it). We don't want to have two linters checking for the same thing as we can end up disabling two warnings that are actually the same on a single line. Signed-off-by: Martin Vrachev <[email protected]>
f0bf488
to
811fa27
Compare
Change the delta argument type from the tuf/api/metadata.py module in Signed.bump_expiration() to include relativedelta as this provides an easier interface for the callers. We are already testing for that inside test/api line 338. Signed-off-by: Martin Vrachev <[email protected]>
I have rebased on top of develop. |
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.
Many thanks for doing this tedious work, Martin! I'll go forward and merge, because it looks like you addressed Jussi's requested change.
@@ -21,7 +21,7 @@ | |||
See LICENSE-MIT OR LICENSE for licensing information. | |||
|
|||
<Purpose> | |||
'test_updater.py' provides a collection of methods that test the public / | |||
'test_updater.py_old' provides a collection of methods that test the public / |
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.
Is this the coding equivalent of the french Verlan? :P Given the short remaining life time of this doc, I say we leave this as is.
Following parallel merges of theupdateframework#1700 (added new test method), and theupdateframework#1710 (started running mypy on tests), ci/cd fails in the develop branch. This is fixed in this patch. Signed-off-by: Lukas Puehringer <[email protected]>
Fixes #1582
Description of the changes being introduced by the pull request:
Start linting the files that test the new code. In order to do that the old test files
had to be excluded. They were are renamed to
test_*_old.py
, so we can add globs/regex to excludethe files testing the old code.
These options will be removed after we remove those files.
Additional
black
,pylint
andmypy
errors were found and had to be addressedbefore we can start linting.
Please verify and check that the pull request fulfills the following
requirements: