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