home *** CD-ROM | disk | FTP | other *** search
/ Maximum CD 2011 June / maximum-cd-2011-06.iso / DiscContents / LibO_3.3.1_Win_x86_install_multi.exe / libreoffice1.cab / test_frozen.py < prev    next >
Encoding:
Python Source  |  2011-02-15  |  1.3 KB  |  49 lines

  1. # Test the frozen module defined in frozen.c.
  2.  
  3. from test.test_support import captured_stdout, run_unittest
  4. import unittest
  5. import sys, os
  6.  
  7. class FrozenTests(unittest.TestCase):
  8.     def test_frozen(self):
  9.  
  10.         with captured_stdout() as stdout:
  11.             try:
  12.                 import __hello__
  13.             except ImportError, x:
  14.                 self.fail("import __hello__ failed:" + str(x))
  15.  
  16.             try:
  17.                 import __phello__
  18.             except ImportError, x:
  19.                 self.fail("import __phello__ failed:" + str(x))
  20.  
  21.             try:
  22.                 import __phello__.spam
  23.             except ImportError, x:
  24.                 self.fail("import __phello__.spam failed:" + str(x))
  25.  
  26.             if sys.platform != "mac":  # On the Mac this import does succeed.
  27.                 try:
  28.                     import __phello__.foo
  29.                 except ImportError:
  30.                     pass
  31.                 else:
  32.                     self.fail("import __phello__.foo should have failed")
  33.  
  34.         self.assertEquals(stdout.getvalue(),
  35.                           'Hello world...\nHello world...\nHello world...\n')
  36.  
  37.         del sys.modules['__hello__']
  38.         del sys.modules['__phello__']
  39.         del sys.modules['__phello__.spam']
  40.  
  41.  
  42. def test_main():
  43.     run_unittest(FrozenTests)
  44.  
  45.  
  46.  
  47. if __name__ == '__main__':
  48.     test_main()
  49.