mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-04-26 20:31:27 -07: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:
parent
bb9ee0cf6f
commit
272ff10fa1
4 changed files with 25 additions and 13 deletions
|
@ -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(),
|
||||
)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue