test_bdist.py 1.8 KB

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