You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
ansible/test/units/plugins
Rick Elrod e2a57414f4 Remove `with` statement for pytest-mock unit tests
As per:
https://github.com/pytest-dev/pytest-mock#note-about-usage-as-context-manager
pytest-mock is not meant to be used within a `with` context or as a
decorator. Instead, pytest-mock will automatically unpatch the mocked
methods when each test is complete.

In newer pytest-mock, this use actually throws an exception and causes
the tests to fail.

This hasn't been hit in Ansible's CI yet, because the docker image
that the tests run in uses an older version of pytest-mock. However,
there is no constraint on the upper bound of pytest-mock in
test/lib/ansible_test/_data/requirements/constraints.txt which means
that when running the tests locally, outside of that docker image, the
tests never pass.

This patch removes the `with` context in each such case.

Signed-off-by: Rick Elrod <rick@elrod.me>
4 years ago
..
action become - stop using play context in more places (#62373) 5 years ago
cache Improve testing of FactCache (#55739) 5 years ago
callback Replace TestCase.assertEquals with TestCase.assertEqual. 5 years ago
cliconf Unit tests: remove unused imports (#59812) 5 years ago
connection new connection plugin aws_ssm (#49652) 5 years ago
filter Clean up flake8 for ansible.netcommon collection (#65842) 5 years ago
httpapi fix all modules to be able to get parameter with value false (very important fix) (#65040) 5 years ago
inventory Replace TestCase.assertEquals with TestCase.assertEqual. 5 years ago
loader_fixtures Don't cache duplicate plugin names (#34420) 7 years ago
lookup Remove `with` statement for pytest-mock unit tests 4 years ago
shell Add support for Windows hosts in the SSH connection plugin (#47732) 5 years ago
strategy throttle: fix linear based strategies (#65422) 5 years ago
terminal Remove empty setUp/tearDown/tearDownClass methods in test classes. 5 years ago
vars Add empty-init code-smell script. (#18406) 8 years ago
__init__.py Add empty-init code-smell script. (#18406) 8 years ago
test_plugins.py Remove empty setUp/tearDown/tearDownClass methods in test classes. 5 years ago