当前位置: 首页>>代码示例>>Python>>正文


Python encoders.encode_noop方法代码示例

本文整理汇总了Python中email.encoders.encode_noop方法的典型用法代码示例。如果您正苦于以下问题:Python encoders.encode_noop方法的具体用法?Python encoders.encode_noop怎么用?Python encoders.encode_noop使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在email.encoders的用法示例。


在下文中一共展示了encoders.encode_noop方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_binary_body_with_encode_noop

# 需要导入模块: from email import encoders [as 别名]
# 或者: from email.encoders import encode_noop [as 别名]
def test_binary_body_with_encode_noop(self):
        # Issue 16564: This does not produce an RFC valid message, since to be
        # valid it should have a CTE of binary.  But the below works, and is
        # documented as working this way.
        bytesdata = b'\xfa\xfb\xfc\xfd\xfe\xff'
        msg = MIMEApplication(bytesdata, _encoder=encoders.encode_noop)
        self.assertEqual(msg.get_payload(), bytesdata)
        self.assertEqual(msg.get_payload(decode=True), bytesdata)
        s = StringIO()
        g = Generator(s)
        g.flatten(msg)
        wireform = s.getvalue()
        msg2 = email.message_from_string(wireform)
        self.assertEqual(msg.get_payload(), bytesdata)
        self.assertEqual(msg2.get_payload(decode=True), bytesdata)


# Test the basic MIMEText class 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:20,代码来源:test_email_renamed.py

示例2: test_binary_body_with_encode_noop

# 需要导入模块: from email import encoders [as 别名]
# 或者: from email.encoders import encode_noop [as 别名]
def test_binary_body_with_encode_noop(self):
        # Issue 16564: This does not produce an RFC valid message, since to be
        # valid it should have a CTE of binary.  But the below works in
        # Python2, and is documented as working this way.
        bytesdata = b'\xfa\xfb\xfc\xfd\xfe\xff'
        msg = MIMEApplication(bytesdata, _encoder=encoders.encode_noop)
        # Treated as a string, this will be invalid code points.
        self.assertEqual(msg.get_payload(), '\uFFFD' * len(bytesdata))
        self.assertEqual(msg.get_payload(decode=True), bytesdata)
        s = BytesIO()
        g = BytesGenerator(s)
        g.flatten(msg)
        wireform = s.getvalue()
        msg2 = email.message_from_bytes(wireform)
        self.assertEqual(msg.get_payload(), '\uFFFD' * len(bytesdata))
        self.assertEqual(msg2.get_payload(decode=True), bytesdata) 
开发者ID:IronLanguages,项目名称:ironpython3,代码行数:18,代码来源:test_email.py

示例3: __init__

# 需要导入模块: from email import encoders [as 别名]
# 或者: from email.encoders import encode_noop [as 别名]
def __init__(self, method, uri, headers, body):
        if isinstance(body, dict):
            body = json.dumps(body)
            headers["Content-Type"] = "application/json"
            headers["Content-Length"] = len(body)
        if body is None:
            body = ""
        lines = ["%s %s HTTP/1.1" % (method, uri)]
        lines.extend(
            ["%s: %s" % (key, value) for key, value in sorted(headers.items())]
        )
        lines.append("")
        lines.append(body)
        payload = "\r\n".join(lines)
        if six.PY2:
            # email.message.Message is an old-style class, so we
            # cannot use 'super()'.
            MIMEApplication.__init__(self, payload, "http", encode_noop)
        else:  # pragma: NO COVER  Python3
            super_init = super(MIMEApplicationHTTP, self).__init__
            super_init(payload, "http", encode_noop) 
开发者ID:googleapis,项目名称:python-storage,代码行数:23,代码来源:batch.py


注:本文中的email.encoders.encode_noop方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。