[issue9298] binary email attachment issue with base64 encoding
Yves Dorfsman
report at bugs.python.org
Thu Feb 10 02:37:01 CET 2011
Yves Dorfsman <yves at zioup.com> added the comment:
#!/usr/bin/python3.1
import unittest
import email.mime.image
class emailEncoderTestCase(unittest.TestCase):
def setUp(self):
# point to an image
binaryfile = ''
#binaryfile = '/usr/share/openclipart/png/animals/mammals/happy_monkey_benji_park_01.png'
while len(binaryfile) == 0:
print('Enter the name of an image: ')
binaryfile = input()
fp = open(binaryfile, 'rb')
self.bindata = fp.read()
def test_convert(self):
mimed = email.mime.image.MIMEImage(self.bindata, _subtype='png')
base64ed = mimed.get_payload()
# print (base64ed)
# work out if any line within the string is > 76 chars
chopped = base64ed.split('\n')
lengths = [ len(x) for x in chopped ]
toolong = [ x for x in lengths if x > 76 ]
msg = 'There is at least one line of ' + str(max(lengths)) + ' chars.'
self.assertEqual(0, len(toolong), msg)
if __name__ == '__main__':
unittest.main()
----------
_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue9298>
_______________________________________
More information about the Python-bugs-list
mailing list