blob: 503a6e857dfc4dcacb2a1c6bfac33e25d230e1a6 [file] [log] [blame]
Tarek Ziadéf6370502009-04-05 22:57:21 +00001"""Tests for distutils.command.bdist."""
Tarek Ziadéf6370502009-04-05 22:57:21 +00002import os
Éric Araujofbe37df2011-08-29 21:48:39 +02003import unittest
Éric Araujo70ec44a2010-11-06 02:44:43 +00004from test.support import run_unittest
Tarek Ziadéf6370502009-04-05 22:57:21 +00005
Tarek Ziadéf6370502009-04-05 22:57:21 +00006from distutils.command.bdist import bdist
7from distutils.tests import support
Éric Araujofbe37df2011-08-29 21:48:39 +02008
Tarek Ziadéf6370502009-04-05 22:57:21 +00009
10class BuildTestCase(support.TempdirManager,
11 unittest.TestCase):
12
13 def test_formats(self):
Tarek Ziadéf6370502009-04-05 22:57:21 +000014 # let's create a command and make sure
Éric Araujofbe37df2011-08-29 21:48:39 +020015 # we can set the format
16 dist = self.create_dist()[1]
Tarek Ziadéf6370502009-04-05 22:57:21 +000017 cmd = bdist(dist)
18 cmd.formats = ['msi']
19 cmd.ensure_finalized()
Ezio Melottib3aedd42010-11-20 19:04:17 +000020 self.assertEqual(cmd.formats, ['msi'])
Tarek Ziadéf6370502009-04-05 22:57:21 +000021
Éric Araujofbe37df2011-08-29 21:48:39 +020022 # what formats does bdist offer?
23 formats = ['bztar', 'gztar', 'msi', 'rpm', 'tar',
24 'wininst', '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
Tarek Ziadéf6370502009-04-05 22:57:21 +000045
46def test_suite():
47 return unittest.makeSuite(BuildTestCase)
48
49if __name__ == '__main__':
Éric Araujo70ec44a2010-11-06 02:44:43 +000050 run_unittest(test_suite())