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:
Toshio Kuratomi 2016-01-20 09:04:44 -08:00
parent e3a6accc1d
commit a68d90a71a
2 changed files with 41 additions and 31 deletions

View file

@ -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')