def test_download_cleanup(self):
    self.client.write('foo/dl', 'hello')
    self.client.write('foo/bar/dl', 'there')
    _read = self.client.read

    def read(hdfs_path, *args, **kwargs):
      if 'bar' in hdfs_path:
        raise RuntimeError()
      return _read(hdfs_path, *args, **kwargs)

    with temppath() as tpath:
      try:
        self.client.read = read
        self.client.download('foo', tpath)
      except RuntimeError:
        ok_(not osp.exists(tpath))
      else:
        ok_(False) # This shouldn't happen.
      finally:
        self.client.read = _read
dataset/ETHPy150Open mtth/hdfs/test/test_client.py/TestDownload.test_download_cleanup/original