def test_dir_exists_true(self, path_mocker_stopall):
# mock
mock_logger_error = path_mocker_stopall.MagicMock(name="mock_logger_error")
mock_path = path_mocker_stopall.MagicMock(name="mock_path")
# patch
path_mocker_stopall.patch.object(scarlett_os.subprocess.logging.Logger, 'error', mock_logger_error)
path_mocker_stopall.patch.object(scarlett_os.internal.path, 'Path', mock_path)
path = '/home/pi/dev/bossjones-github/scarlett_os/_debug'
mock_path_instance = mock_path()
#
mock_path_instance.is_dir.return_value = True
# run test
s_path.dir_exists(path)
# assert
assert mock_logger_error.call_count == 0
assert mock_path_instance.is_dir.call_count == 2
mock_logger_error.assert_not_called()
评论列表
文章目录