mirror of
https://github.com/ansible-collections/community.general.git
synced 2026-04-12 20:00:58 +00:00
rework run_command's env setting to not change os.environ for the rest of the module.
New param to run_command to modify the environment for just this invocation. Documentation and comment adjustments.
This commit is contained in:
@@ -39,6 +39,7 @@ class OpenStringIO(StringIO):
|
||||
def close(self):
|
||||
pass
|
||||
|
||||
|
||||
@unittest.skipIf(sys.version_info[0] >= 3, "Python 3 is not supported on targets (yet)")
|
||||
class TestAnsibleModuleRunCommand(unittest.TestCase):
|
||||
|
||||
@@ -111,10 +112,6 @@ class TestAnsibleModuleRunCommand(unittest.TestCase):
|
||||
self.assertEqual(args, ('ls a " b" "c "', ))
|
||||
self.assertEqual(kwargs['shell'], True)
|
||||
|
||||
def test_path_prefix(self):
|
||||
self.module.run_command('foo', path_prefix='/opt/bin')
|
||||
self.assertEqual('/opt/bin', self.os.environ['PATH'].split(':')[0])
|
||||
|
||||
def test_cwd(self):
|
||||
self.os.getcwd.return_value = '/old'
|
||||
self.module.run_command('/bin/ls', cwd='/new')
|
||||
|
||||
Reference in New Issue
Block a user