test_tarfile.py 文件源码

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

项目:zippy 作者: securesystemslab 项目源码 文件源码
def test_fileobj_readlines(self):
        self.tar.extract("ustar/regtype", TEMPDIR)
        tarinfo = self.tar.getmember("ustar/regtype")
        with open(os.path.join(TEMPDIR, "ustar/regtype"), "r") as fobj1:
            lines1 = fobj1.readlines()

        fobj = self.tar.extractfile(tarinfo)
        try:
            fobj2 = io.TextIOWrapper(fobj)
            lines2 = fobj2.readlines()
            self.assertTrue(lines1 == lines2,
                    "fileobj.readlines() failed")
            self.assertTrue(len(lines2) == 114,
                    "fileobj.readlines() failed")
            self.assertTrue(lines2[83] ==
                    "I will gladly admit that Python is not the fastest running scripting language.\n",
                    "fileobj.readlines() failed")
        finally:
            fobj.close()
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号