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

Pytest 4 1 compliant #26

Merged
merged 6 commits into from
Jan 17, 2019
Merged

Pytest 4 1 compliant #26

merged 6 commits into from
Jan 17, 2019

Conversation

vgramer
Copy link
Contributor

@vgramer vgramer commented Jan 8, 2019

This PR fix the tests in order to be compliant with pytest 4.1

I have split the PR in many commits in order make the review easier. I can squash the commits if you wish.

Please pay attention to commit b65d104 beacause i haven't find a doc that explain why this return code has changed. The new return code EXIT_USAGEERROR seems logic to me but ...

The tests on ansible_devel are failing because of a breaking change on ansible python API. CLI.base_parser() does not exist anymore

original warning message raise during test:
/perso/pytest-ansible/tests/conftest.py:68: RemovedInPytest4Warning: usage of Function.Function is deprecated, please use pytest.Function instead
Original warning message raise durig tests:
/pytest-ansible/tests/test_module_result.py:119: RemovedInPytest4Warning: getfuncargvalue is deprecated, use getfixturevalue
Original warning message raise durig tests:
tests/test_module_dispatcher.py:32: RemovedInPytest4Warning: Applying marks directly to parameters is deprecated, please use pytest.param(..., marks=...) instead.
For more details, see: https://docs.pytest.org/en/latest/parametrize.html
@pytest.mark.parametrize("host_pattern, num_hosts", POSITIVE_HOST_PATTERNS)
previously the test was expecting  EXIT_INTERRUPTED return code but pytest actualy returns EXIT_USAGEERROR return code
the test was failling because more than one warning was raised. Instead of to test the number of warning (wich is IMHO just to avoid exception when testing message if no warning was raised )
we test that at leat one warning with the message 'provided hosts list is empty, only localhost is available' has been raised
…node.get_marker(...)

Original warning message raise durig tests:
_pytest.warning_types.RemovedInPytest4Warning: MarkInfo objects are deprecated as they contain merged marks which are hard to deal with correctly.
Please use node.get_closest_marker(name) or node.iter_markers(name).
Docs: https://docs.pytest.org/en/latest/mark.html#updating-code
@jlaska
Copy link
Contributor

jlaska commented Jan 17, 2019

@vgramer This is great, thank you for the contribution!

@jlaska jlaska merged commit cdf6cca into ansible:master Jan 17, 2019
@vgramer vgramer deleted the pytest_4_1_compliant branch January 18, 2019 12:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants