Home | History | Annotate | Download | only in tests
      1 """Tests for distutils.util."""
      2 import sys
      3 import unittest
      4 from test.test_support import run_unittest
      5 
      6 from distutils.errors import DistutilsPlatformError, DistutilsByteCompileError
      7 from distutils.util import byte_compile
      8 
      9 class UtilTestCase(unittest.TestCase):
     10 
     11     def test_dont_write_bytecode(self):
     12         # makes sure byte_compile raise a DistutilsError
     13         # if sys.dont_write_bytecode is True
     14         old_dont_write_bytecode = sys.dont_write_bytecode
     15         sys.dont_write_bytecode = True
     16         try:
     17             self.assertRaises(DistutilsByteCompileError, byte_compile, [])
     18         finally:
     19             sys.dont_write_bytecode = old_dont_write_bytecode
     20 
     21 def test_suite():
     22     return unittest.makeSuite(UtilTestCase)
     23 
     24 if __name__ == "__main__":
     25     run_unittest(test_suite())
     26