mirror of
https://github.com/ansible-collections/community.general.git
synced 2026-04-16 22:01:15 +00:00
Fix @contextmanager leak on exception. (#21031)
* Fix @contextmanager leak on exception. * Fix test leaks of global module args cache.
This commit is contained in:
@@ -311,6 +311,7 @@ class TestModuleUtilsBasic(ModuleTestCase):
|
||||
args = json.dumps(dict(ANSIBLE_MODULE_ARGS={"foo":"hello", "bar": "bad", "bam": "bad"}))
|
||||
|
||||
with swap_stdin_and_argv(stdin_data=args):
|
||||
basic._ANSIBLE_ARGS = None
|
||||
self.assertRaises(
|
||||
SystemExit,
|
||||
basic.AnsibleModule,
|
||||
@@ -327,6 +328,7 @@ class TestModuleUtilsBasic(ModuleTestCase):
|
||||
args = json.dumps(dict(ANSIBLE_MODULE_ARGS={"bam": "bad"}))
|
||||
|
||||
with swap_stdin_and_argv(stdin_data=args):
|
||||
basic._ANSIBLE_ARGS = None
|
||||
self.assertRaises(
|
||||
SystemExit,
|
||||
basic.AnsibleModule,
|
||||
@@ -580,12 +582,11 @@ class TestModuleUtilsBasic(ModuleTestCase):
|
||||
|
||||
def test_module_utils_basic_ansible_module_is_special_selinux_path(self):
|
||||
from ansible.module_utils import basic
|
||||
basic._ANSIBLE_ARGS = None
|
||||
|
||||
args = json.dumps(dict(ANSIBLE_MODULE_ARGS={'_ansible_selinux_special_fs': "nfs,nfsd,foos"}))
|
||||
|
||||
with swap_stdin_and_argv(stdin_data=args):
|
||||
|
||||
basic._ANSIBLE_ARGS = None
|
||||
am = basic.AnsibleModule(
|
||||
argument_spec = dict(),
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user