Tarek Ziadé | f637050 | 2009-04-05 22:57:21 +0000 | [diff] [blame] | 1 | """Tests for distutils.command.bdist.""" |
Tarek Ziadé | f637050 | 2009-04-05 22:57:21 +0000 | [diff] [blame] | 2 | import os |
Éric Araujo | fbe37df | 2011-08-29 21:48:39 +0200 | [diff] [blame] | 3 | import unittest |
Éric Araujo | 70ec44a | 2010-11-06 02:44:43 +0000 | [diff] [blame] | 4 | from test.support import run_unittest |
Tarek Ziadé | f637050 | 2009-04-05 22:57:21 +0000 | [diff] [blame] | 5 | |
Tarek Ziadé | f637050 | 2009-04-05 22:57:21 +0000 | [diff] [blame] | 6 | from distutils.command.bdist import bdist |
| 7 | from distutils.tests import support |
Éric Araujo | fbe37df | 2011-08-29 21:48:39 +0200 | [diff] [blame] | 8 | |
Tarek Ziadé | f637050 | 2009-04-05 22:57:21 +0000 | [diff] [blame] | 9 | |
| 10 | class BuildTestCase(support.TempdirManager, |
| 11 | unittest.TestCase): |
| 12 | |
| 13 | def test_formats(self): |
Tarek Ziadé | f637050 | 2009-04-05 22:57:21 +0000 | [diff] [blame] | 14 | # let's create a command and make sure |
Éric Araujo | fbe37df | 2011-08-29 21:48:39 +0200 | [diff] [blame] | 15 | # we can set the format |
| 16 | dist = self.create_dist()[1] |
Tarek Ziadé | f637050 | 2009-04-05 22:57:21 +0000 | [diff] [blame] | 17 | cmd = bdist(dist) |
| 18 | cmd.formats = ['msi'] |
| 19 | cmd.ensure_finalized() |
Ezio Melotti | b3aedd4 | 2010-11-20 19:04:17 +0000 | [diff] [blame] | 20 | self.assertEqual(cmd.formats, ['msi']) |
Tarek Ziadé | f637050 | 2009-04-05 22:57:21 +0000 | [diff] [blame] | 21 | |
Éric Araujo | fbe37df | 2011-08-29 21:48:39 +0200 | [diff] [blame] | 22 | # 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é | f637050 | 2009-04-05 22:57:21 +0000 | [diff] [blame] | 45 | |
| 46 | def test_suite(): |
| 47 | return unittest.makeSuite(BuildTestCase) |
| 48 | |
| 49 | if __name__ == '__main__': |
Éric Araujo | 70ec44a | 2010-11-06 02:44:43 +0000 | [diff] [blame] | 50 | run_unittest(test_suite()) |