test_rand.py 文件源码

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

项目:OneClickDTU 作者: satwikkansal 项目源码 文件源码
def _read_write_test(self, path):
        """
        Verify that ``rand.write_file`` and ``rand.load_file`` can be used.
        """
        # Create the file so cleanup is more straightforward
        with open(path, "w"):
            pass

        try:
            # Write random bytes to a file
            rand.write_file(path)

            # Verify length of written file
            size = os.stat(path)[stat.ST_SIZE]
            self.assertEqual(1024, size)

            # Read random bytes from file
            rand.load_file(path)
            rand.load_file(path, 4)  # specify a length
        finally:
            # Cleanup
            os.unlink(path)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号