Tools: Fix run_filter_test.py to not confuse pytest discovery#30443
Closed
cclauss wants to merge 1 commit intoArduPilot:masterfrom
Closed
Tools: Fix run_filter_test.py to not confuse pytest discovery#30443cclauss wants to merge 1 commit intoArduPilot:masterfrom
run_filter_test.py to not confuse pytest discovery#30443cclauss wants to merge 1 commit intoArduPilot:masterfrom
Conversation
`Tools/FilterTestTool/run_filter_test.py` has a filename that will make Pytest Discovery think that it should be tested. * https://docs.pytest.org/en/stable/explanation/goodpractices.html#conventions-for-python-test-discovery This script also has code ___at global scope___ that will fail if certain command line arguments are not provided. The proposed change is to put that code under `if __name__ == "__main__":` so it will not be run at test time. * https://docs.python.org/3/library/__main__.html Search for `run_filter_test`: * https://github.com/search?q=repo%3AArduPilot%2Fardupilot%20run_filter_test&type=code How was this tested? 1. `pytest Tools/scripts/build_tests/test_ccache.py` 2. `pytest Tools` Both of the above find no tests instead of crashing with a confusing error.
a00a462 to
406fd43
Compare
run_filter_test.py to not confuse pytest discovery
Contributor
|
This might be another candidate for aging out. We need to test a log through it to make sure it's not broken but there is for sure some old stuff in it... I agree with the making it python3-specific. |
Contributor
Author
|
Closing because even with these changes, |
Contributor
|
Why don't we put pytest tests in an allowlisted folder? |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Tools/FilterTestTool/run_filter_test.pyhas a filename that will make Pytest Discovery think that it should be tested.This script also has code at global scope that will fail if certain command line arguments are not provided.
The proposed change is to put that code under
if __name__ == "__main__":so it will not be run at test time.Search for
run_filter_test:How was this tested?
pytest Tools/FilterTestTool/run_filter_test.pypytest ToolsBoth of the above find no tests instead of crashing with a confusing error.