decoder.py 文件源码

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

项目:mongoengine_utils 作者: aiscenblue 项目源码 文件源码
def setUp(self):
        """Setup test."""
        from base64 import b64encode, b64decode
        from bson.binary import Binary, BINARY_SUBTYPE

        class BinaryTest(db.Document):
            text = db.BinaryField()

        self.model_cls = BinaryTest
        self.data = {
            "text": {
                "data": b64encode(
                    ("This is a test").encode("utf-8")
                ).decode("utf-8"),
                "type": BINARY_SUBTYPE
            }
        }
        self.expected_data = {
            "text": Binary(
                b64decode(self.data["text"]["data"]),
                self.data["text"]["type"]
            )
        }
        self.data = json.dumps(self.data)

        self.hook = generate_object_hook(BinaryTest)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号