test_archive_4.py 811 B

12345678910111213141516171819202122232425262728
  1. def test_zip_extract_ro(self):
  2. src = os.path.join(self.tmp, "src")
  3. os.mkdir(src)
  4. # Create a empty dir called a, and two files named
  5. # b and c
  6. a = os.path.join(src, "a")
  7. os.mkdir(a)
  8. ro = os.path.join(a, "ro")
  9. with open(ro, "w") as fp:
  10. fp.write("ro\n")
  11. # 200:
  12. os.chmod(ro, stat.S_IRUSR)
  13. archive = qibuild.archive.zip(a)
  14. dest = os.path.join(self.tmp, "dest")
  15. os.mkdir(dest)
  16. qibuild.archive.extract(archive, dest)
  17. ls_r = qibuild.sh.ls_r(dest)
  18. self.assertEquals(ls_r, ["a/ro"])
  19. dest_ro = os.path.join(dest, "a", "ro")
  20. # check that the dest is readonly:
  21. error = None
  22. try:
  23. open(dest_ro, "w")
  24. except IOError as e:
  25. error = e
  26. self.assertFalse(error is None)
  27. self.assertEquals(error.errno, errno.EACCES)