ansible/test
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>
2020-01-29 13:29:40 -08:00
..
ansible_test
integration vmware_vswitch/test: clean up vmswitch_0002 2020-01-29 14:32:57 -05:00
legacy
lib/ansible_test Forbid state=(list|info) in modules via ansible-test sanity check 2020-01-29 21:06:36 +01:00
sanity Forbid state=(list|info) in modules via ansible-test sanity check 2020-01-29 21:06:36 +01:00
units Remove with statement for pytest-mock unit tests 2020-01-29 13:29:40 -08:00
utils Consolidate remote Shippable scripts. 2020-01-28 17:48:54 -08:00