test.py 文件源码

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

项目:jgscm 作者: src-d 项目源码 文件源码
def test_save_file(self):
        self.contents_manager.save({
            "type": "file",
            "content": "blah-blah-blah",
            "format": "text"
        }, self.path("test.txt"))
        bucket = self.bucket
        blob = bucket.blob("test.txt")
        self.assertTrue(blob.exists())
        try:
            self.assertEqual(blob.download_as_string(), b"blah-blah-blah")
        finally:
            blob.delete()

        obj = {"one": 1, "two": [2, 3]}
        self.contents_manager.save({
            "type": "file",
            "content": base64.encodebytes(pickle.dumps(obj)).decode("ascii"),
            "format": "base64"
        }, self.path("test.pickle"))
        bucket = self.bucket
        blob = bucket.blob("test.pickle")
        self.assertTrue(blob.exists())
        try:
            self.assertEqual(blob.download_as_string(), pickle.dumps(obj))
        finally:
            blob.delete()
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号