This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author yves@zioup.com
Recipients r.david.murray, vunruh, yves@zioup.com
Date 2011-02-10.01:30:04
SpamBayes Score 1.8346946e-05
Marked as misclassified No
Message-id <1297301405.11.0.495679800542.issue9298@psf.upfronthosting.co.za>
In-reply-to
Content
#!/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()
History
Date User Action Args
2011-02-10 01:30:05yves@zioup.comsetrecipients: + yves@zioup.com, r.david.murray, vunruh
2011-02-10 01:30:05yves@zioup.comsetmessageid: <1297301405.11.0.495679800542.issue9298@psf.upfronthosting.co.za>
2011-02-10 01:30:04yves@zioup.comlinkissue9298 messages
2011-02-10 01:30:04yves@zioup.comcreate