<s> import sys <EOL> import os <EOL> import unittest <EOL> from io import StringIO <EOL> from types import ListType <EOL> from email . test . test_email import TestEmailBase <EOL> from test . support import TestSkipped , run_unittest <EOL> import email <EOL> from email import __file__ as testfile <EOL> from email . iterators import _structure <EOL> def openfile ( filename ) : <EOL> from os . path import join , dirname , abspath <EOL> path = abspath ( join ( dirname ( testfile ) , os . pardir , '<STR_LIT>' , filename ) ) <EOL> return open ( path , '<STR_LIT:r>' ) <EOL> try : <EOL> openfile ( '<STR_LIT>' ) <EOL> except IOError : <EOL> raise TestSkipped <EOL> class TortureBase ( TestEmailBase ) : <EOL> def _msgobj ( self , filename ) : <EOL> fp = openfile ( filename ) <EOL> try : <EOL> msg = email . message_from_file ( fp ) <EOL> finally : <EOL> fp . close ( ) <EOL> return msg <EOL> class TestCrispinTorture ( TortureBase ) : <EOL> def test_mondo_message ( self ) : <EOL> eq = self . assertEqual <EOL> neq = self . ndiffAssertEqual <EOL> msg = self . _msgobj ( '<STR_LIT>' ) <EOL> payload = msg . get_payload ( ) <EOL> eq ( type ( payload ) , ListType ) <EOL> eq ( len ( payload ) , <NUM_LIT:12> ) <EOL> eq ( msg . preamble , None ) <EOL> eq ( msg . epilogue , '<STR_LIT:\n>' ) <EOL> fp = StringIO ( ) <EOL> _structure ( msg , fp = fp ) <EOL> neq ( fp . getvalue ( ) , """<STR_LIT>""" ) <EOL> def _testclasses ( ) : <EOL> mod = sys . modules [ __name__ ] <EOL> return [ getattr ( mod , name ) for name in dir ( mod ) if name . startswith ( '<STR_LIT>' ) ] <EOL> def suite ( ) : <EOL> suite = unittest . TestSuite ( ) <EOL> for testclass in _testclasses ( ) : <EOL> suite . addTest ( unittest . makeSuite ( testclass ) ) <EOL> return suite <EOL> def test_main ( ) : <EOL> for testclass in _testclasses ( ) : <EOL> run_unittest ( testclass ) <EOL> if __name__ == '<STR_LIT:__main__>' : <EOL> unittest . main ( defaultTest = '<STR_LIT>' ) </s>
