Message128255
#!/usr/bin/python3.1
import unittest
import email.mime.image
class emailEncoderTestCase(unittest.TestCase):
def setUp(self):
# point to an image
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 = raw_input()
fp = open('/usr/share/openclipart/png/animals/mammals/happy_monkey_benji_park_01.png', '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() |
|
Date |
User |
Action |
Args |
2011-02-10 01:30:05 | yves@zioup.com | set | recipients:
+ yves@zioup.com, r.david.murray, vunruh |
2011-02-10 01:30:05 | yves@zioup.com | set | messageid: <1297301405.11.0.495679800542.issue9298@psf.upfronthosting.co.za> |
2011-02-10 01:30:04 | yves@zioup.com | link | issue9298 messages |
2011-02-10 01:30:04 | yves@zioup.com | create | |
|