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


Python MIMEImage.get_payload方法代码示例

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


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

示例1: test_custom_encoder

# 需要导入模块: from email.MIMEImage import MIMEImage [as 别名]
# 或者: from email.MIMEImage.MIMEImage import get_payload [as 别名]
 def test_custom_encoder(self):
     eq = self.assertEqual
     def encoder(msg):
         orig = msg.get_payload()
         msg.set_payload(0)
         msg['Content-Transfer-Encoding'] = 'broken64'
     im = MIMEImage(self._imgdata, _encoder=encoder)
     eq(im.get_payload(), 0)
     eq(im['content-transfer-encoding'], 'broken64')
开发者ID:mancoast,项目名称:CPythonPyc_test,代码行数:11,代码来源:221_test_email.py

示例2: TestMIMEImage

# 需要导入模块: from email.MIMEImage import MIMEImage [as 别名]
# 或者: from email.MIMEImage.MIMEImage import get_payload [as 别名]
class TestMIMEImage(unittest.TestCase):
    def setUp(self):
        fp = openfile('PyBanner048.gif')
        try:
            self._imgdata = fp.read()
        finally:
            fp.close()
        self._im = MIMEImage(self._imgdata)

    def test_guess_minor_type(self):
        self.assertEqual(self._im.get_type(), 'image/gif')

    def test_encoding(self):
        payload = self._im.get_payload()
        self.assertEqual(base64.decodestring(payload), self._imgdata)

    def checkSetMinor(self):
        im = MIMEImage(self._imgdata, 'fish')
        self.assertEqual(im.get_type(), 'image/fish')

    def test_custom_encoder(self):
        eq = self.assertEqual
        def encoder(msg):
            orig = msg.get_payload()
            msg.set_payload(0)
            msg['Content-Transfer-Encoding'] = 'broken64'
        im = MIMEImage(self._imgdata, _encoder=encoder)
        eq(im.get_payload(), 0)
        eq(im['content-transfer-encoding'], 'broken64')

    def test_add_header(self):
        eq = self.assertEqual
        unless = self.failUnless
        self._im.add_header('Content-Disposition', 'attachment',
                            filename='dingusfish.gif')
        eq(self._im['content-disposition'],
           'attachment; filename="dingusfish.gif"')
        eq(self._im.get_params(header='content-disposition'),
           [('attachment', ''), ('filename', 'dingusfish.gif')])
        eq(self._im.get_param('filename', header='content-disposition'),
           'dingusfish.gif')
        missing = []
        eq(self._im.get_param('attachment', header='content-disposition'), '')
        unless(self._im.get_param('foo', failobj=missing,
                                  header='content-disposition') is missing)
        # Try some missing stuff
        unless(self._im.get_param('foobar', missing) is missing)
        unless(self._im.get_param('attachment', missing,
                                  header='foobar') is missing)
开发者ID:mancoast,项目名称:CPythonPyc_test,代码行数:51,代码来源:221_test_email.py

示例3: Copyright

# 需要导入模块: from email.MIMEImage import MIMEImage [as 别名]
# 或者: from email.MIMEImage.MIMEImage import get_payload [as 别名]
# Copyright (C) 2001 Python Software Foundation
开发者ID:mcyril,项目名称:ravel-ftn,代码行数:3,代码来源:test_email.py


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