t_misc.py 文件源码

python
阅读 21 收藏 0 点赞 0 评论 0

项目:solaris-ips 作者: oracle 项目源码 文件源码
def testMakedirs(self):
                tmpdir = tempfile.mkdtemp()
                # make the parent directory read-write
                os.chmod(tmpdir, stat.S_IRWXU)
                fpath = os.path.join(tmpdir, "f")
                fopath = os.path.join(fpath, "o")
                foopath = os.path.join(fopath, "o")

                # make the leaf, and ONLY the leaf read-only
                act = action.fromstr("dir path={0}".format(foopath))
                act.makedirs(foopath, mode = stat.S_IREAD)

                # Now make sure the directories leading up the leaf
                # are read-write, and the leaf is readonly.
                assert(os.stat(tmpdir).st_mode & (stat.S_IREAD | stat.S_IWRITE) != 0)
                assert(os.stat(fpath).st_mode & (stat.S_IREAD | stat.S_IWRITE) != 0)
                assert(os.stat(fopath).st_mode & (stat.S_IREAD | stat.S_IWRITE) != 0)
                assert(os.stat(foopath).st_mode & stat.S_IREAD != 0)
                assert(os.stat(foopath).st_mode & stat.S_IWRITE == 0)

                # change it back to read/write so we can delete it
                os.chmod(foopath, stat.S_IRWXU)
                shutil.rmtree(tmpdir)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号