| 1 |
"""Tests for distutils.command.bdist.""" |
| 2 |
import os |
| 3 |
import unittest |
| 4 |
|
| 5 |
from test.test_support import run_unittest |
| 6 |
|
| 7 |
from distutils.command.bdist import bdist |
| 8 |
from distutils.tests import support |
| 9 |
|
| 10 |
|
| 11 |
class BuildTestCase(support.TempdirManager, |
| 12 |
unittest.TestCase): |
| 13 |
|
| 14 |
def test_formats(self): |
| 15 |
|
| 16 |
|
| 17 |
dist = self.create_dist()[1] |
| 18 |
cmd = bdist(dist) |
| 19 |
cmd.formats = ['msi'] |
| 20 |
cmd.ensure_finalized() |
| 21 |
self.assertEqual(cmd.formats, ['msi']) |
| 22 |
|
| 23 |
|
| 24 |
formats = ['bztar', 'gztar', 'msi', 'rpm', 'tar', |
| 25 |
'wininst', 'zip', 'ztar'] |
| 26 |
found = sorted(cmd.format_command) |
| 27 |
self.assertEqual(found, formats) |
| 28 |
|
| 29 |
def test_skip_build(self): |
| 30 |
|
| 31 |
dist = self.create_dist()[1] |
| 32 |
cmd = bdist(dist) |
| 33 |
cmd.skip_build = 1 |
| 34 |
cmd.ensure_finalized() |
| 35 |
dist.command_obj['bdist'] = cmd |
| 36 |
|
| 37 |
names = ['bdist_dumb', 'bdist_wininst'] |
| 38 |
|
| 39 |
if os.name == 'nt': |
| 40 |
names.append('bdist_msi') |
| 41 |
|
| 42 |
for name in names: |
| 43 |
subcmd = cmd.get_finalized_command(name) |
| 44 |
self.assertTrue(subcmd.skip_build, |
| 45 |
'%s should take --skip-build from bdist' % name) |
| 46 |
|
| 47 |
|
| 48 |
def test_suite(): |
| 49 |
return unittest.makeSuite(BuildTestCase) |
| 50 |
|
| 51 |
if __name__ == '__main__': |
| 52 |
run_unittest(test_suite()) |