test_bdist.py 1.5 KB

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