Skip to content
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

test helper: improvements #9672

Merged

Conversation

russoz
Copy link
Collaborator

@russoz russoz commented Feb 2, 2025

changes:

  • methods from_module(), from_file() and from_spec() now all have a similar order of parameters
  • from_module() tries extensions .yaml and .yml before giving up
  • remove redundant parameter test_spec from from_module()
  • from_file() now receives an open, readable, file handle instead of a filename
  • Helper no longer accepts a test specification that is a top-level list of testcases, it must be a dict containing the key test_cases, which will be the list.
  • test_snap.py adjusted for the change in from_spec()
SUMMARY
ISSUE TYPE
  • Test Pull Request
COMPONENT NAME

tests/unit/plugins/modules/helper.py
tests/unit/plugins/modules/test_snap.py

changes:
- methods `from_module()`, `from_file()` and `from_spec()` now all have a similar order of parameters
- `from_module()` tries extensions `.yaml` and `.yml` before giving up
- remove redundant parameter `test_spec` from `from_module()`
- `from_file()` now receives an open, readable, file handle instead of a filename
- `Helper` no longer accepts a test specification that is a top-level list of testcases, it must be a dict containing the key `test_cases`, which will be the list.
- test_snap.py adjusted for the change in `from_spec()`
@ansibullbot ansibullbot added tests tests unit tests/unit labels Feb 2, 2025
@ansibullbot
Copy link
Collaborator

The test ansible-test sanity --test compile --python 2.7 [explain] failed with 1 error:

tests/unit/plugins/modules/helper.py:40:105: SyntaxError: raise FileNotFoundError(f"Cannot find test case file for {0} with one of the extensions: {1}".format(test_module.__file__, ", ".join(extensions)))

click here for bot help

@ansibullbot ansibullbot added the needs_revision This PR fails CI tests or a maintainer has requested a review/revision of the PR label Feb 2, 2025
@felixfontein felixfontein added check-before-release PR will be looked at again shortly before release and merged if possible. backport-10 Automatically create a backport for the stable-10 branch labels Feb 2, 2025
@russoz russoz merged commit 7a6125b into ansible-collections:main Feb 2, 2025
138 checks passed
Copy link

patchback bot commented Feb 2, 2025

Backport to stable-10: 💚 backport PR created

✅ Backport PR branch: patchback/backports/stable-10/7a6125b99a000dbbd572514bc796da6bb3973af9/pr-9672

Backported as #9673

🤖 @patchback
I'm built with octomachinery and
my source is open — https://github.com/sanitizers/patchback-github-app.

@russoz russoz deleted the test-helper-refactor2 branch February 2, 2025 08:46
@felixfontein felixfontein removed the check-before-release PR will be looked at again shortly before release and merged if possible. label Feb 2, 2025
patchback bot pushed a commit that referenced this pull request Feb 2, 2025
(cherry picked from commit 7a6125b)
felixfontein pushed a commit that referenced this pull request Feb 2, 2025
)

test helper: improvements (#9672)

(cherry picked from commit 7a6125b)

Co-authored-by: Alexei Znamensky <[email protected]>
Massl123 pushed a commit to Massl123/community.general that referenced this pull request Feb 7, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport-10 Automatically create a backport for the stable-10 branch needs_revision This PR fails CI tests or a maintainer has requested a review/revision of the PR tests tests unit tests/unit
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants