test_archive_7.py 726 B

123456789101112131415161718192021
  1. def test_extract_change_topdir(self):
  2. src = os.path.join(self.tmp, "src")
  3. os.mkdir(src)
  4. a_long_dir = os.path.join(src, "a_long_dir")
  5. os.mkdir(a_long_dir)
  6. b = os.path.join(a_long_dir, "b")
  7. with open(b, "w") as fp:
  8. fp.write("b\n")
  9. dest = os.path.join(self.tmp, "dest")
  10. os.mkdir(dest)
  11. tar_gz = qibuild.archive.zip_unix(a_long_dir)
  12. qibuild.archive.extract(tar_gz, dest, topdir="a")
  13. a = os.path.join(dest, "a")
  14. ls_r = qibuild.sh.ls_r(a)
  15. self.assertEquals(ls_r, ["b"])
  16. a_zip = qibuild.archive.zip_win(a_long_dir)
  17. qibuild.archive.extract(a_zip, dest, topdir="aa")
  18. aa = os.path.join(dest, "aa")
  19. ls_r = qibuild.sh.ls_r(aa)
  20. self.assertEquals(ls_r, ["b"])