Yves Dorfsman <y...@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 <rep...@bugs.python.org> <http://bugs.python.org/issue9298> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com