• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 = ['msi']
22        cmd.ensure_finalized()
23        self.assertEqual(cmd.formats, ['msi'])
24
25        # what formats does bdist offer?
26        formats = ['bztar', 'gztar', 'msi', 'rpm', 'tar',
27                   'xztar', 'zip', 'ztar']
28        found = sorted(cmd.format_command)
29        self.assertEqual(found, formats)
30
31    def test_skip_build(self):
32        # bug #10946: bdist --skip-build should trickle down to subcommands
33        dist = self.create_dist()[1]
34        cmd = bdist(dist)
35        cmd.skip_build = 1
36        cmd.ensure_finalized()
37        dist.command_obj['bdist'] = cmd
38
39        names = ['bdist_dumb']  # bdist_rpm does not support --skip-build
40        if os.name == 'nt':
41            names.append('bdist_msi')
42
43        for name in names:
44            subcmd = cmd.get_finalized_command(name)
45            if getattr(subcmd, '_unsupported', False):
46                # command is not supported on this build
47                continue
48            self.assertTrue(subcmd.skip_build,
49                            '%s should take --skip-build from bdist' % name)
50
51
52def test_suite():
53    return unittest.makeSuite(BuildTestCase)
54
55if __name__ == '__main__':
56    run_unittest(test_suite())
57