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
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>
5 years ago
..
cli Fix using a URL for galaxy collection install (#65272) 5 years ago
compat Move unit test compat code out of `lib/ansible/`. (#46996) 6 years ago
config config manager str type vault source (#65023) 5 years ago
contrib Fix vmware_inventory unit tests so they run. 6 years ago
errors Remove empty overridden unittest.setUp and unittest.tearDown methods. 5 years ago
executor Add mechanism for storing warnings and deprecations outside of AnsibleModule (#58993) 5 years ago
galaxy Rename private function (#66577) 5 years ago
inventory_test_data/group_vars
mock Replace TestCase.assertEquals with TestCase.assertEqual. 5 years ago
module_utils Remove `with` statement for pytest-mock unit tests 5 years ago
modules When no pool quantity is set, then do not set quantity to 1 (#66807) 5 years ago
parsing Replace TestCase.assertEquals with TestCase.assertEqual. 5 years ago
playbook Check if task file is specified for import_tasks (#57572) 5 years ago
plugins Remove `with` statement for pytest-mock unit tests 5 years ago
regex Add toggle to control invalid character substitution in group names (#52748) 6 years ago
template Do not treat AnsibleUndefined as being unsafe (#65202) 5 years ago
utils display - remove extra new line after warning message (#65199) 5 years ago
vars Remove empty setUp/tearDown/tearDownClass methods in test classes. 5 years ago
__init__.py
requirements.txt Fix ansible-test collections requirements installation. (#62181) 5 years ago
test_constants.py
test_context.py Unit tests: remove unused imports (#59740) 5 years ago