def _cleanup_dir_stack(self): for location in reversed(self.dir_stack): try: Path.remove_hierarchy(self.root_dir + location) except Exception as e: log.warning('Failed to remove directory %s: %s', location, format(e)) del self.dir_stack[:]
def _cleanup_dir_stack(self): for location in reversed(self.dir_stack): try: Path.remove_hierarchy(self.root_dir + location) except Exception as e: log.warning( 'Failed to remove directory %s: %s', location, format(e) ) del self.dir_stack[:]
def test_remove_hierarchy(self, mock_log_warn, mock_command): Path.remove_hierarchy('/my_root/tmp/foo/bar') assert mock_command.call_args_list == [ call(['rmdir', '--ignore-fail-on-non-empty', '/my_root/tmp/foo/bar']), call(['rmdir', '--ignore-fail-on-non-empty', '/my_root/tmp/foo']) ] mock_log_warn.assert_called_once_with( 'remove_hierarchy: path /my_root/tmp is protected' )
def _cleanup_dir_stack(self): for location in reversed(self.dir_stack): try: Path.remove_hierarchy(root=self.root_dir, path=location) except Exception as e: log.warning( 'Failed to remove directory hierarchy {0}: {1}'.format( self.root_dir + location, e)) del self.dir_stack[:]
def test_remove_hierarchy(self, mock_command): Path.remove_hierarchy('/my_root/tmp/foo/bar') with self._caplog.at_level(logging.WARNING): assert mock_command.call_args_list == [ call([ 'rmdir', '--ignore-fail-on-non-empty', '/my_root/tmp/foo/bar' ]), call([ 'rmdir', '--ignore-fail-on-non-empty', '/my_root/tmp/foo' ]) ] assert 'remove_hierarchy: path /my_root/tmp is protected' in \ self._caplog.text
def test_remove_hierarchy(self, mock_command): Path.remove_hierarchy('foo') mock_command.assert_called_once_with( ['rmdir', '-p', '--ignore-fail-on-non-empty', 'foo'])
def test_remove_hierarchy(self, mock_command): Path.remove_hierarchy('foo') mock_command.assert_called_once_with( ['rmdir', '-p', '--ignore-fail-on-non-empty', 'foo'] )