ansible/test/units
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
..
cli Fix using a URL for galaxy collection install (#65272) 2019-12-03 04:55:31 +10:00
compat Move unit test compat code out of lib/ansible/. (#46996) 2018-10-12 20:01:14 -07:00
config config manager str type vault source (#65023) 2019-11-20 12:02:28 +10:00
contrib Fix vmware_inventory unit tests so they run. 2018-10-09 22:52:04 -07:00
errors Remove empty overridden unittest.setUp and unittest.tearDown methods. 2019-11-05 09:12:11 -08:00
executor Add mechanism for storing warnings and deprecations outside of AnsibleModule (#58993) 2020-01-28 12:12:14 -05:00
galaxy Rename private function (#66577) 2020-01-17 15:27:15 -05:00
inventory_test_data/group_vars
mock Replace TestCase.assertEquals with TestCase.assertEqual. 2019-11-11 10:24:21 -08:00
module_utils Remove with statement for pytest-mock unit tests 2020-01-29 13:29:40 -08:00
modules When no pool quantity is set, then do not set quantity to 1 (#66807) 2020-01-29 12:10:47 -05:00
parsing Replace TestCase.assertEquals with TestCase.assertEqual. 2019-11-11 10:24:21 -08:00
playbook Check if task file is specified for import_tasks (#57572) 2019-12-24 10:26:32 +05:30
plugins Remove with statement for pytest-mock unit tests 2020-01-29 13:29:40 -08:00
regex Add toggle to control invalid character substitution in group names (#52748) 2019-03-06 11:49:40 -05:00
template Do not treat AnsibleUndefined as being unsafe (#65202) 2019-11-25 15:06:29 +01:00
utils display - remove extra new line after warning message (#65199) 2020-01-24 12:10:04 -05:00
vars Remove empty setUp/tearDown/tearDownClass methods in test classes. 2019-11-06 08:14:29 -08:00
__init__.py
requirements.txt Fix ansible-test collections requirements installation. (#62181) 2019-09-12 02:00:33 -07:00
test_constants.py
test_context.py Unit tests: remove unused imports (#59740) 2019-07-29 22:10:13 +02:00