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

Move ansiblelint.testing.RunFromText import into test code #1827

Merged
merged 1 commit into from
Jan 24, 2022

Conversation

cognifloyd
Copy link
Contributor

@cognifloyd cognifloyd commented Jan 24, 2022

Some of the rules were importing test code even outside of the testing block. This fixes that so there are no unintended side-effects of importing the testing code.

In particular, importing that testing code should be delayed so that prepare_environment() doesn't get called when importing the rule:
https://github.com/ansible-community/ansible-lint/blob/main/src/ansiblelint/testing/__init__.py#L19-L21
It probably doesn't make a difference, but it was a code smell, so this cleans that up.

@cognifloyd cognifloyd requested a review from a team as a code owner January 24, 2022 17:56
@cognifloyd cognifloyd requested review from relrod, cidrblock and priyamsahoo and removed request for a team January 24, 2022 17:56
@cognifloyd
Copy link
Contributor Author

I'm not sure what to do about codecov here. How does moving an import into test code change the code coverage? Odd.

@ssbarnea
Copy link
Member

@cognifloyd I will check, from time to time I need to ignore coverage result. Rounding errors can make it go down.

@ssbarnea ssbarnea added the bug label Jan 24, 2022
@ssbarnea ssbarnea merged commit 8ec0519 into ansible:main Jan 24, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants