Message128257
#!/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() |
|
Date |
User |
Action |
Args |
2011-02-10 01:37:01 | yves@zioup.com | set | recipients:
+ yves@zioup.com, r.david.murray, vunruh |
2011-02-10 01:37:01 | yves@zioup.com | set | messageid: <1297301821.42.0.483400048749.issue9298@psf.upfronthosting.co.za> |
2011-02-10 01:37:00 | yves@zioup.com | link | issue9298 messages |
2011-02-10 01:37:00 | yves@zioup.com | create | |
|