1"""Tests for distutils.command.bdist.""" 2import os 3import unittest 4from test.support import run_unittest 5 6from distutils.command.bdist import bdist 7from distutils.tests import support 8 9 10class 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 self.assertTrue(subcmd.skip_build, 43 '%s should take --skip-build from bdist' % name) 44 45 46def test_suite(): 47 return unittest.makeSuite(BuildTestCase) 48 49if __name__ == '__main__': 50 run_unittest(test_suite()) 51