我们从Python开源项目中,提取了以下41个代码示例,用于说明如何使用email.MIMEImage()。
def test_add_header(self): eq = self.assertEqual unless = self.failUnless self._au.add_header('Content-Disposition', 'attachment', filename='audiotest.au') eq(self._au['content-disposition'], 'attachment; filename="audiotest.au"') eq(self._au.get_params(header='content-disposition'), [('attachment', ''), ('filename', 'audiotest.au')]) eq(self._au.get_param('filename', header='content-disposition'), 'audiotest.au') missing = [] eq(self._au.get_param('attachment', header='content-disposition'), '') unless(self._au.get_param('foo', failobj=missing, header='content-disposition') is missing) # Try some missing stuff unless(self._au.get_param('foobar', missing) is missing) unless(self._au.get_param('attachment', missing, header='foobar') is missing) # Test the basic MIMEImage class
def test_add_header(self): eq = self.assertEqual self._au.add_header('Content-Disposition', 'attachment', filename='audiotest.au') eq(self._au['content-disposition'], 'attachment; filename="audiotest.au"') eq(self._au.get_params(header='content-disposition'), [('attachment', ''), ('filename', 'audiotest.au')]) eq(self._au.get_param('filename', header='content-disposition'), 'audiotest.au') missing = [] eq(self._au.get_param('attachment', header='content-disposition'), '') self.assertIs(self._au.get_param('foo', failobj=missing, header='content-disposition'), missing) # Try some missing stuff self.assertIs(self._au.get_param('foobar', missing), missing) self.assertIs(self._au.get_param('attachment', missing, header='foobar'), missing) # Test the basic MIMEImage class
def test__all__(self): module = __import__('email') all = module.__all__ all.sort() self.assertEqual(all, [ # Old names 'Charset', 'Encoders', 'Errors', 'Generator', 'Header', 'Iterators', 'MIMEAudio', 'MIMEBase', 'MIMEImage', 'MIMEMessage', 'MIMEMultipart', 'MIMENonMultipart', 'MIMEText', 'Message', 'Parser', 'Utils', 'base64MIME', # new names 'base64mime', 'charset', 'encoders', 'errors', 'generator', 'header', 'iterators', 'message', 'message_from_file', 'message_from_string', 'mime', 'parser', 'quopriMIME', 'quoprimime', 'utils', ])
def test_add_header(self): eq = self.assertEqual unless = self.assertTrue self._au.add_header('Content-Disposition', 'attachment', filename='audiotest.au') eq(self._au['content-disposition'], 'attachment; filename="audiotest.au"') eq(self._au.get_params(header='content-disposition'), [('attachment', ''), ('filename', 'audiotest.au')]) eq(self._au.get_param('filename', header='content-disposition'), 'audiotest.au') missing = [] eq(self._au.get_param('attachment', header='content-disposition'), '') unless(self._au.get_param('foo', failobj=missing, header='content-disposition') is missing) # Try some missing stuff unless(self._au.get_param('foobar', missing) is missing) unless(self._au.get_param('attachment', missing, header='foobar') is missing) # Test the basic MIMEImage class
def setUp(self): fp = openfile('PyBanner048.gif') try: self._imgdata = fp.read() finally: fp.close() self._im = MIMEImage(self._imgdata)
def test_checkSetMinor(self): im = MIMEImage(self._imgdata, 'fish') self.assertEqual(im.get_content_type(), 'image/fish')