# email_tests.py # Test email.message_from_string with various strings import email msg_list = [('leading whitespace', ''' Line 1 Line 2 Line 3 '''), ('left justified', '''Line 1 Line 2 Line 3 ''') ] for name, body in msg_list: m = email.message_from_string(body) in_lines = len(body.splitlines()) out_lines = len(m.get_payload().splitlines()) print name, ':' if in_lines != out_lines: print ' Body changed: lines in:', in_lines, ' lines out:', out_lines else: print ' Line count was preserved.'