home *** CD-ROM | disk | FTP | other *** search
/ Maximum CD 2010 November / maximum-cd-2010-11.iso / DiscContents / calibre-0.7.13.msi / file_450 (.txt) < prev    next >
Encoding:
Python Compiled Bytecode  |  2010-08-06  |  4.3 KB  |  82 lines

  1. # Source Generated with Decompyle++
  2. # File: in.pyc (Python 2.6)
  3.  
  4. import sys
  5. import os
  6. import unittest
  7. from cStringIO import StringIO
  8. from types import ListType
  9. from email.test.test_email import TestEmailBase
  10. from test.test_support import TestSkipped
  11. import email
  12. from email import __file__ as testfile
  13. from email.iterators import _structure
  14.  
  15. def openfile(filename):
  16.     join = join
  17.     dirname = dirname
  18.     abspath = abspath
  19.     import os.path
  20.     path = abspath(join(dirname(testfile), os.pardir, 'moredata', filename))
  21.     return open(path, 'r')
  22.  
  23.  
  24. try:
  25.     openfile('crispin-torture.txt')
  26. except IOError:
  27.     raise TestSkipped
  28.  
  29.  
  30. class TortureBase(TestEmailBase):
  31.     
  32.     def _msgobj(self, filename):
  33.         fp = openfile(filename)
  34.         
  35.         try:
  36.             msg = email.message_from_file(fp)
  37.         finally:
  38.             fp.close()
  39.  
  40.         return msg
  41.  
  42.  
  43.  
  44. class TestCrispinTorture(TortureBase):
  45.     
  46.     def test_mondo_message(self):
  47.         eq = self.assertEqual
  48.         neq = self.ndiffAssertEqual
  49.         msg = self._msgobj('crispin-torture.txt')
  50.         payload = msg.get_payload()
  51.         eq(type(payload), ListType)
  52.         eq(len(payload), 12)
  53.         eq(msg.preamble, None)
  54.         eq(msg.epilogue, '\n')
  55.         fp = StringIO()
  56.         _structure(msg, fp = fp)
  57.         neq(fp.getvalue(), 'multipart/mixed\n    text/plain\n    message/rfc822\n        multipart/alternative\n            text/plain\n            multipart/mixed\n                text/richtext\n            application/andrew-inset\n    message/rfc822\n        audio/basic\n    audio/basic\n    image/pbm\n    message/rfc822\n        multipart/mixed\n            multipart/mixed\n                text/plain\n                audio/x-sun\n            multipart/mixed\n                image/gif\n                image/gif\n                application/x-be2\n                application/atomicmail\n            audio/x-sun\n    message/rfc822\n        multipart/mixed\n            text/plain\n            image/pgm\n            text/plain\n    message/rfc822\n        multipart/mixed\n            text/plain\n            image/pbm\n    message/rfc822\n        application/postscript\n    image/gif\n    message/rfc822\n        multipart/mixed\n            audio/basic\n            audio/basic\n    message/rfc822\n        multipart/mixed\n            application/postscript\n            text/plain\n            message/rfc822\n                multipart/mixed\n                    text/plain\n                    multipart/parallel\n                        image/gif\n                        audio/basic\n                    application/atomicmail\n                    message/rfc822\n                        audio/x-sun\n')
  58.  
  59.  
  60.  
  61. def _testclasses():
  62.     mod = sys.modules[__name__]
  63.     return _[1]
  64.  
  65.  
  66. def suite():
  67.     suite = unittest.TestSuite()
  68.     for testclass in _testclasses():
  69.         suite.addTest(unittest.makeSuite(testclass))
  70.     
  71.     return suite
  72.  
  73.  
  74. def test_main():
  75.     for testclass in _testclasses():
  76.         test_support.run_unittest(testclass)
  77.     
  78.  
  79. if __name__ == '__main__':
  80.     unittest.main(defaultTest = 'suite')
  81.  
  82.