def test_zip_extract_ro(self): src = os.path.join(self.tmp, "src") os.mkdir(src) # Create a empty dir called a, and two files named # b and c a = os.path.join(src, "a") os.mkdir(a) ro = os.path.join(a, "ro") with open(ro, "w") as fp: fp.write("ro\n") # 200: os.chmod(ro, stat.S_IRUSR) archive = qibuild.archive.zip(a) dest = os.path.join(self.tmp, "dest") os.mkdir(dest) qibuild.archive.extract(archive, dest) ls_r = qibuild.sh.ls_r(dest) self.assertEquals(ls_r, ["a/ro"]) dest_ro = os.path.join(dest, "a", "ro") # check that the dest is readonly: error = None try: open(dest_ro, "w") except IOError as e: error = e self.assertFalse(error is None) self.assertEquals(error.errno, errno.EACCES)