Skip to content

Commit d1b30a1

Browse files
committed
os.path.exists should be mocked in test case
This commit mocks os.path.exists in the test case test_start_iscsi_target_fail_wait_daemon in extensions.iscsi.TestISCSIExtension. If this isn't mocked, the file can coincidentally exist on the environment and can cause failure. Change-Id: Ibaa8fcae51faaaefc2764411d02621f347d99c03
1 parent 8173927 commit d1b30a1

1 file changed

Lines changed: 2 additions & 0 deletions

File tree

  • ironic_python_agent/tests/extensions

ironic_python_agent/tests/extensions/iscsi.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
# under the License.
1717

1818
import mock
19+
import os
1920
import time
2021

2122
from oslo_concurrency import processutils
@@ -64,6 +65,7 @@ def test_start_iscsi_target(self, mock_wait_iscsi, mock_execute,
6465
self.assertEqual({'iscsi_target_iqn': self.fake_iqn},
6566
result.command_result)
6667

68+
@mock.patch.object(os.path, 'exists', lambda x: False)
6769
def test_start_iscsi_target_fail_wait_daemon(self, mock_execute,
6870
mock_dispatch):
6971
mock_dispatch.return_value = self.fake_dev

0 commit comments

Comments
 (0)