test_bdist.py 1.6 KB

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