summaryrefslogtreecommitdiff
path: root/tests/unittests/test_handler/test_handler_growpart.py
diff options
context:
space:
mode:
authorScott Moser <smoser@brickies.net>2016-09-21 15:45:45 -0400
committerScott Moser <smoser@brickies.net>2016-09-21 16:33:19 -0400
commit40a400e42603aa1b80d9f623bc779799b370c091 (patch)
treec6b06266be9ba57f5764290d04d61584e732512c /tests/unittests/test_handler/test_handler_growpart.py
parent970dbd13f5ae40b0f95ea390b72d2b3426e8e4d9 (diff)
downloadvyos-cloud-init-40a400e42603aa1b80d9f623bc779799b370c091.tar.gz
vyos-cloud-init-40a400e42603aa1b80d9f623bc779799b370c091.zip
subp: add 'update_env' argument
In order for a caller to use 'env' argument of subp, they will realistically do: env = os.environ.copy() env['FOO'] = 'BZR' subp(cmd, env=env) This shortens that to be: subp(cmd, update_env={'FOO': 'BZR'}) Add tests, and update growpart tests to use mock when playing with os.environ.
Diffstat (limited to 'tests/unittests/test_handler/test_handler_growpart.py')
-rw-r--r--tests/unittests/test_handler/test_handler_growpart.py4
1 files changed, 3 insertions, 1 deletions
diff --git a/tests/unittests/test_handler/test_handler_growpart.py b/tests/unittests/test_handler/test_handler_growpart.py
index e653488a..e28067de 100644
--- a/tests/unittests/test_handler/test_handler_growpart.py
+++ b/tests/unittests/test_handler/test_handler_growpart.py
@@ -81,11 +81,11 @@ class TestConfig(TestCase):
self.cloud = cloud.Cloud(None, self.paths, None, None, None)
self.log = logging.getLogger("TestConfig")
self.args = []
- os.environ = {}
self.cloud_init = None
self.handle = cc_growpart.handle
+ @mock.patch.dict("os.environ", clear=True)
def test_no_resizers_auto_is_fine(self):
with mock.patch.object(
util, 'subp',
@@ -98,6 +98,7 @@ class TestConfig(TestCase):
mockobj.assert_called_once_with(
['growpart', '--help'], env={'LANG': 'C'})
+ @mock.patch.dict("os.environ", clear=True)
def test_no_resizers_mode_growpart_is_exception(self):
with mock.patch.object(
util, 'subp',
@@ -110,6 +111,7 @@ class TestConfig(TestCase):
mockobj.assert_called_once_with(
['growpart', '--help'], env={'LANG': 'C'})
+ @mock.patch.dict("os.environ", clear=True)
def test_mode_auto_prefers_growpart(self):
with mock.patch.object(
util, 'subp',