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.
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
Force collections to be static #68723
Force collections to be static #68723
Changes from all commits
5fd5113
e49dd6e
0334164
459c954
5cac2ed
5c7b52d
File filter
Filter by extension
Conversations
Jump to
There are no files selected for viewing
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 does that method return? Can we have an equality check here?
Also, is there a public method that could be called instead of the private one?
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.
It returns a list of collection names and is adding 'ansible.legacy' to that list. I'm not aware of a public method to call instead.
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.
If the order is deterministic, you could have a more precise check 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.
Well, in this test case, it should always be the first element based on the current code. But in this case, we don't actually care about positioning, just that it appears anywhere in the list, independent of which other collections are inserted. Do you feel always checking against the first element is better? That could open it up to test failures if we later decide to alter the ordering for some reason that I cannot yet foresee.
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 either way is fine. But in general, I prefer tests to be as precise as possible to prevent some buggy behavior from squeezing in just because it has similar properties.
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 use equality which would be more precise and replace that check that you had earlier with calls count == 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 was using IN here because it seems the capsys output contains color-coding chars and newlines so IN was easier to use for confirming the main data here (warning + collection name) is present.
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.
Right, you could probably monkeypatch
ANSIBLE_COLOR
:ansible/lib/ansible/utils/color.py
Line 91 in 598ead9
But I looked closer at the display function and it looks like it uses an actual logger from
logging
stdlib module (ansible/lib/ansible/utils/display.py
Line 216 in 598ead9
You should be able to use the
caplog
fixture. Let me see if I can quickly come up with a patch.