Home | History | Annotate | Download | only in tests
      1 """Tests for distutils.command.bdist."""
      2 import os
      3 import unittest
      4 from test.support import run_unittest
      5 
      6 from distutils.command.bdist import bdist
      7 from distutils.tests import support
      8 
      9 
     10 class BuildTestCase(support.TempdirManager,
     11                     unittest.TestCase):
     12 
     13     def test_formats(self):
     14         # let's create a command and make sure
     15         # we can set the format
     16         dist = self.create_dist()[1]
     17         cmd = bdist(dist)
     18         cmd.formats = ['msi']
     19         cmd.ensure_finalized()
     20         self.assertEqual(cmd.formats, ['msi'])
     21 
     22         # what formats does bdist offer?
     23         formats = ['bztar', 'gztar', 'msi', 'rpm', 'tar',
     24                    'wininst', 'xztar', 'zip', 'ztar']
     25         found = sorted(cmd.format_command)
     26         self.assertEqual(found, formats)
     27 
     28     def test_skip_build(self):
     29         # bug #10946: bdist --skip-build should trickle down to subcommands
     30         dist = self.create_dist()[1]
     31         cmd = bdist(dist)
     32         cmd.skip_build = 1
     33         cmd.ensure_finalized()
     34         dist.command_obj['bdist'] = cmd
     35 
     36         names = ['bdist_dumb', 'bdist_wininst']  # bdist_rpm does not support --skip-build
     37         if os.name == 'nt':
     38             names.append('bdist_msi')
     39 
     40         for name in names:
     41             subcmd = cmd.get_finalized_command(name)
     42             if getattr(subcmd, '_unsupported', False):
     43                 # command is not supported on this build
     44                 continue
     45             self.assertTrue(subcmd.skip_build,
     46                             '%s should take --skip-build from bdist' % name)
     47 
     48 
     49 def test_suite():
     50     return unittest.makeSuite(BuildTestCase)
     51 
     52 if __name__ == '__main__':
     53     run_unittest(test_suite())
     54