-
Notifications
You must be signed in to change notification settings - Fork 23.7k
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
Fix collection loader and add unit tests. #58701
Merged
Merged
Conversation
This file contains 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
This fixes two issues: 1. File names are available when tracing execution, such as with code coverage. 2. Future statements are not inherited from the collection loader.
These tests verify several things: 1. That unit tests can import code from collections when the collection loader is installed. 2. That tracing reports the correct file and line numbers (to support code coverage). 3. That collection code does not inherit __future__ statements from the collection loader.
ansibot
added
affects_2.9
This issue/PR affects Ansible v2.9
bug
This issue/PR relates to a bug.
core_review
In order to be merged, this PR must follow the core review workflow.
needs_triage
Needs a first human triage before being processed.
new_plugin
This PR includes a new plugin.
support:core
This issue/PR relates to code supported by the Ansible Engineering Team.
needs_revision
This PR fails CI tests or a maintainer has requested a review/revision of the PR.
and removed
core_review
In order to be merged, this PR must follow the core review workflow.
labels
Jul 4, 2019
Since the collection loader is installed simply by importing ansible.plugins.loader, we may already have a collection loader installed when the test runs. This occurs if any other tests are collected which use that import during collection. Until that code is moved into an initialization function to avoid loading during import, the unit tests will need to replace any existing collection loaders so that they reflect the desired configuration.
mattclay
removed
the
needs_triage
Needs a first human triage before being processed.
label
Jul 4, 2019
ansibot
added
core_review
In order to be merged, this PR must follow the core review workflow.
and removed
needs_revision
This PR fails CI tests or a maintainer has requested a review/revision of the PR.
labels
Jul 4, 2019
This is a requirement of PEP 302. It will prevent recursion errors when importing the current module or using a relative import.
This allows using relative imports in collections.
The relative-beyond-top-level rule in pylint may not be appropriate for collections. However, until that rule is disabled for collections this will keep tests passing.
ansibot
added
needs_revision
This PR fails CI tests or a maintainer has requested a review/revision of the PR.
core_review
In order to be merged, this PR must follow the core review workflow.
and removed
core_review
In order to be merged, this PR must follow the core review workflow.
needs_revision
This PR fails CI tests or a maintainer has requested a review/revision of the PR.
labels
Jul 8, 2019
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Labels
affects_2.9
This issue/PR affects Ansible v2.9
bug
This issue/PR relates to a bug.
core_review
In order to be merged, this PR must follow the core review workflow.
new_plugin
This PR includes a new plugin.
support:core
This issue/PR relates to code supported by the Ansible Engineering Team.
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.
SUMMARY
Fix collection loader and add unit tests.
ISSUE TYPE
Bugfix Pull Request
COMPONENT NAME
collection loader
ADDITIONAL INFORMATION
Use
compile
beforeeval
in collection loader.This fixes two issues:
Add unit tests for collection loading.
These tests verify several things:
__future__
statements from the collection loader.