<s> """<STR_LIT>""" <EOL> import unittest , StringIO <EOL> from test . test_support import run_unittest , import_module <EOL> import_module ( "<STR_LIT>" , deprecated = True ) <EOL> from MimeWriter import MimeWriter <EOL> SELLER = '''<STR_LIT>''' <EOL> BUYER = '''<STR_LIT>''' <EOL> STATE = '''<STR_LIT>''' <EOL> SIMPLE_METADATA = [ <EOL> ( "<STR_LIT>" , "<STR_LIT>" ) , <EOL> ( "<STR_LIT>" , "<STR_LIT>" ) , <EOL> ( "<STR_LIT>" , "<STR_LIT>" ) , <EOL> ( "<STR_LIT>" , "<STR_LIT>" ) , <EOL> ( "<STR_LIT>" , "<STR_LIT>" ) , <EOL> ( "<STR_LIT>" , "<STR_LIT>" ) , <EOL> ( "<STR_LIT>" , "<STR_LIT>" ) , <EOL> ] <EOL> COMPLEX_METADATA = [ <EOL> ( "<STR_LIT>" , "<STR_LIT>" ) , <EOL> ( "<STR_LIT>" , "<STR_LIT>" ) , <EOL> ( "<STR_LIT>" , "<STR_LIT>" ) , <EOL> ( "<STR_LIT>" , "<STR_LIT>" ) , <EOL> ( "<STR_LIT>" , "<STR_LIT>" ) , <EOL> ( "<STR_LIT>" , "<STR_LIT>" ) , <EOL> ] <EOL> EXTERNAL_METADATA = [ <EOL> ( "<STR_LIT>" , "<STR_LIT>" ) , <EOL> ( "<STR_LIT>" , "<STR_LIT>" ) , <EOL> ( "<STR_LIT>" , "<STR_LIT>" ) , <EOL> ( "<STR_LIT>" , "<STR_LIT>" ) , <EOL> ( "<STR_LIT>" , "<STR_LIT>" ) , <EOL> ( "<STR_LIT>" , "<STR_LIT>" ) , <EOL> ] <EOL> OUTPUT = '''<STR_LIT>''' <EOL> class MimewriterTest ( unittest . TestCase ) : <EOL> def test ( self ) : <EOL> buf = StringIO . StringIO ( ) <EOL> toplevel = MimeWriter ( buf ) <EOL> toplevel . addheader ( "<STR_LIT>" , "<STR_LIT>" ) <EOL> toplevel . addheader ( "<STR_LIT>" , "<STR_LIT>" ) <EOL> toplevel . addheader ( "<STR_LIT>" , "<STR_LIT>" ) <EOL> toplevel . addheader ( "<STR_LIT>" , "<STR_LIT:1.0>" ) <EOL> f = toplevel . startmultipartbody ( "<STR_LIT>" , "<STR_LIT>" , <EOL> [ ( "<STR_LIT:version>" , "<STR_LIT>" ) ] , prefix = <NUM_LIT:0> ) <EOL> f . write ( "<STR_LIT>" ) <EOL> md = toplevel . nextpart ( ) <EOL> md . startmultipartbody ( "<STR_LIT>" , "<STR_LIT>" ) <EOL> md1 = md . nextpart ( ) <EOL> md1 . addheader ( "<STR_LIT>" , "<STR_LIT>" ) <EOL> md1 . addheader ( "<STR_LIT>" , "<STR_LIT>" ) <EOL> m = MimeWriter ( md1 . startbody ( "<STR_LIT>" ) ) <EOL> for key , value in SIMPLE_METADATA : <EOL> m . addheader ( "<STR_LIT>" + key , value ) <EOL> m . flushheaders ( ) <EOL> del md1 <EOL> md2 = md . nextpart ( ) <EOL> for key , value in COMPLEX_METADATA : <EOL> md2 . addheader ( "<STR_LIT>" + key , value ) <EOL> f = md2 . startbody ( "<STR_LIT>" ) <EOL> f . write ( SELLER ) <EOL> del md2 <EOL> md3 = md . nextpart ( ) <EOL> f = md3 . startbody ( "<STR_LIT>" , <EOL> [ ( "<STR_LIT>" , "<STR_LIT>" ) , <EOL> ( "<STR_LIT>" , "<STR_LIT>" ) ] ) <EOL> m = MimeWriter ( f ) <EOL> for key , value in EXTERNAL_METADATA : <EOL> md3 . addheader ( "<STR_LIT>" + key , value ) <EOL> md3 . startbody ( "<STR_LIT>" ) <EOL> md . lastpart ( ) <EOL> code = toplevel . nextpart ( ) <EOL> code . startmultipartbody ( "<STR_LIT>" , "<STR_LIT>" ) <EOL> buyer = code . nextpart ( ) <EOL> buyer . addheader ( "<STR_LIT>" , "<STR_LIT>" ) <EOL> f = buyer . startbody ( "<STR_LIT>" ) <EOL> f . write ( BUYER ) <EOL> code . lastpart ( ) <EOL> state = toplevel . nextpart ( ) <EOL> state . addheader ( "<STR_LIT>" , "<STR_LIT>" ) <EOL> state . startmultipartbody ( "<STR_LIT>" , "<STR_LIT>" ) <EOL> st = state . nextpart ( ) <EOL> st . addheader ( "<STR_LIT>" , "<STR_LIT>" ) <EOL> f = st . startbody ( "<STR_LIT>" ) <EOL> f . write ( STATE ) <EOL> state . lastpart ( ) <EOL> toplevel . lastpart ( ) <EOL> self . assertEqual ( buf . getvalue ( ) , OUTPUT ) <EOL> def test_main ( ) : <EOL> run_unittest ( MimewriterTest ) <EOL> if __name__ == '<STR_LIT:__main__>' : <EOL> test_main ( ) </s>
