diff options
author | Zuul <zuul@review.opendev.org> | 2021-11-03 14:19:52 +0000 |
---|---|---|
committer | Gerrit Code Review <review@openstack.org> | 2021-11-03 14:19:52 +0000 |
commit | 65827b3015a2ec513a8430c583c2f91b11cd3db5 (patch) | |
tree | c73d20df0798b585db235147c7dc866418db4b7a | |
parent | 67eddfa7e3fedbb530045f5b43a2c89db832fa2a (diff) | |
parent | b360214cf222dd91fda214dac419789e16a79bfe (diff) | |
download | ironic-python-agent-65827b3015a2ec513a8430c583c2f91b11cd3db5.tar.gz |
Merge "Stop requiring mocking of utils.execute if ironic-lib execute is mocked"
-rw-r--r-- | ironic_python_agent/tests/unit/base.py | 3 | ||||
-rw-r--r-- | ironic_python_agent/tests/unit/test_base.py | 15 |
2 files changed, 1 insertions, 17 deletions
diff --git a/ironic_python_agent/tests/unit/base.py b/ironic_python_agent/tests/unit/base.py index 7d14821f..09019e08 100644 --- a/ironic_python_agent/tests/unit/base.py +++ b/ironic_python_agent/tests/unit/base.py @@ -25,7 +25,6 @@ from oslotest import base as test_base from ironic_python_agent.extensions import base as ext_base from ironic_python_agent import hardware -from ironic_python_agent import utils CONF = cfg.CONF @@ -58,7 +57,7 @@ class IronicAgentTest(test_base.BaseTestCase): self.patch(subprocess, 'call', do_not_call) self.patch(subprocess, 'check_call', do_not_call) self.patch(subprocess, 'check_output', do_not_call) - self.patch(utils, 'execute', do_not_call) + # ironic_python_agent.utils.execute is an alias of ironic_lib one ext_base._EXT_MANAGER = None hardware._CACHED_HW_INFO = None diff --git a/ironic_python_agent/tests/unit/test_base.py b/ironic_python_agent/tests/unit/test_base.py index 37bcac3a..3b182ca0 100644 --- a/ironic_python_agent/tests/unit/test_base.py +++ b/ironic_python_agent/tests/unit/test_base.py @@ -50,21 +50,6 @@ class BlockExecuteTestCase(ironic_agent_base.IronicAgentTest): utils.execute("echo") self.assertEqual(2, mock_exec.call_count) - @mock.patch.object(ironic_lib.utils, "execute", autospec=True) - def test_exception_raised_for_execute_parent_mocked(self, mock_exec): - # Make sure that even if we mock the parent execute function, that we - # still get an exception for a child. So in this case utils.execute() - # calls ironic_lib.utils.execute(). Make sure an exception is raised - # even though we mocked ironic_lib.utils.execute() - exc = self.assertRaises(Exception, utils.execute, "ls") # noqa - # Have to use 'noqa' as we are raising plain Exception and we will get - # H202 error in 'pep8' check. - - self.assertEqual( - "Don't call ironic_lib.utils.execute() / " - "processutils.execute() or similar functions in tests!", - "%s" % exc) - class DontBlockExecuteTestCase(ironic_agent_base.IronicAgentTest): """Ensure we can turn off blocking access to 'execute' type functions""" |