test_logging.py 文件源码

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

项目:x-mario-center 作者: fossasia 项目源码 文件源码
def test_no_write_access_for_cache_dir(self):
        """ test for bug LP: #688682 """
        # make the test cache dir non-writeable
        import softwarecenter.paths
        cache_dir = softwarecenter.paths.SOFTWARE_CENTER_CACHE_DIR
        # set not-writable (mode 0400)
        os.chmod(cache_dir, stat.S_IRUSR)
        self.assertFalse(os.access(cache_dir, os.W_OK))
        # and then start up the logger
        import softwarecenter.log
        softwarecenter.log # pyflakes
        # check that the old directory was moved aside (renamed with a ".0" appended)
        self.assertTrue(os.path.exists(cache_dir + ".0"))
        self.assertFalse(os.path.exists(cache_dir + ".1"))
        # and check that the new directory was created and is now writable
        self.assertTrue(os.path.exists(cache_dir))
        self.assertTrue(os.access(cache_dir, os.W_OK))
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号