Merged revisions 72624 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk ........ r72624 | tarek.ziade | 2009-05-14 16:56:14 +0200 (Thu, 14 May 2009) | 1 line pep8-fied distutils.command.sdist + more tests ........
This commit is contained in:
parent
434caaab75
commit
da0dc2e468
|
@ -31,7 +31,7 @@ def show_formats():
|
||||||
FancyGetopt(formats).print_help(
|
FancyGetopt(formats).print_help(
|
||||||
"List of available source distribution formats:")
|
"List of available source distribution formats:")
|
||||||
|
|
||||||
class sdist (Command):
|
class sdist(Command):
|
||||||
|
|
||||||
description = "create a source distribution (tarball, zip file, etc.)"
|
description = "create a source distribution (tarball, zip file, etc.)"
|
||||||
|
|
||||||
|
@ -78,8 +78,8 @@ class sdist (Command):
|
||||||
negative_opt = {'no-defaults': 'use-defaults',
|
negative_opt = {'no-defaults': 'use-defaults',
|
||||||
'no-prune': 'prune' }
|
'no-prune': 'prune' }
|
||||||
|
|
||||||
default_format = { 'posix': 'gztar',
|
default_format = {'posix': 'gztar',
|
||||||
'nt': 'zip' }
|
'nt': 'zip' }
|
||||||
|
|
||||||
def initialize_options(self):
|
def initialize_options(self):
|
||||||
# 'template' and 'manifest' are, respectively, the names of
|
# 'template' and 'manifest' are, respectively, the names of
|
||||||
|
@ -101,7 +101,6 @@ class sdist (Command):
|
||||||
|
|
||||||
self.archive_files = None
|
self.archive_files = None
|
||||||
|
|
||||||
|
|
||||||
def finalize_options(self):
|
def finalize_options(self):
|
||||||
if self.manifest is None:
|
if self.manifest is None:
|
||||||
self.manifest = "MANIFEST"
|
self.manifest = "MANIFEST"
|
||||||
|
@ -125,7 +124,6 @@ class sdist (Command):
|
||||||
if self.dist_dir is None:
|
if self.dist_dir is None:
|
||||||
self.dist_dir = "dist"
|
self.dist_dir = "dist"
|
||||||
|
|
||||||
|
|
||||||
def run(self):
|
def run(self):
|
||||||
# 'filelist' contains the list of files that will make up the
|
# 'filelist' contains the list of files that will make up the
|
||||||
# manifest
|
# manifest
|
||||||
|
@ -244,7 +242,6 @@ class sdist (Command):
|
||||||
else:
|
else:
|
||||||
self.read_manifest()
|
self.read_manifest()
|
||||||
|
|
||||||
|
|
||||||
def add_defaults(self):
|
def add_defaults(self):
|
||||||
"""Add all the default files to self.filelist:
|
"""Add all the default files to self.filelist:
|
||||||
- README or README.txt
|
- README or README.txt
|
||||||
|
@ -373,7 +370,7 @@ class sdist (Command):
|
||||||
vcs_ptrn = r'(^|%s)(%s)(%s).*' % (seps, '|'.join(vcs_dirs), seps)
|
vcs_ptrn = r'(^|%s)(%s)(%s).*' % (seps, '|'.join(vcs_dirs), seps)
|
||||||
self.filelist.exclude_pattern(vcs_ptrn, is_regex=1)
|
self.filelist.exclude_pattern(vcs_ptrn, is_regex=1)
|
||||||
|
|
||||||
def write_manifest (self):
|
def write_manifest(self):
|
||||||
"""Write the file list in 'self.filelist' (presumably as filled in
|
"""Write the file list in 'self.filelist' (presumably as filled in
|
||||||
by 'add_defaults()' and 'read_template()') to the manifest file
|
by 'add_defaults()' and 'read_template()') to the manifest file
|
||||||
named by 'self.manifest'.
|
named by 'self.manifest'.
|
||||||
|
|
|
@ -13,7 +13,7 @@ from distutils.command.sdist import sdist
|
||||||
from distutils.command.sdist import show_formats
|
from distutils.command.sdist import show_formats
|
||||||
from distutils.core import Distribution
|
from distutils.core import Distribution
|
||||||
from distutils.tests.test_config import PyPIRCCommandTestCase
|
from distutils.tests.test_config import PyPIRCCommandTestCase
|
||||||
from distutils.errors import DistutilsExecError
|
from distutils.errors import DistutilsExecError, DistutilsOptionError
|
||||||
from distutils.spawn import find_executable
|
from distutils.spawn import find_executable
|
||||||
from distutils.tests import support
|
from distutils.tests import support
|
||||||
from distutils.archive_util import ARCHIVE_FORMATS
|
from distutils.archive_util import ARCHIVE_FORMATS
|
||||||
|
@ -224,6 +224,28 @@ class sdistTestCase(PyPIRCCommandTestCase):
|
||||||
if line.strip().startswith('--formats=')]
|
if line.strip().startswith('--formats=')]
|
||||||
self.assertEquals(len(output), num_formats)
|
self.assertEquals(len(output), num_formats)
|
||||||
|
|
||||||
|
def test_finalize_options(self):
|
||||||
|
|
||||||
|
dist, cmd = self.get_cmd()
|
||||||
|
cmd.finalize_options()
|
||||||
|
|
||||||
|
# default options set by finalize
|
||||||
|
self.assertEquals(cmd.manifest, 'MANIFEST')
|
||||||
|
self.assertEquals(cmd.template, 'MANIFEST.in')
|
||||||
|
self.assertEquals(cmd.dist_dir, 'dist')
|
||||||
|
|
||||||
|
# formats has to be a string splitable on (' ', ',') or
|
||||||
|
# a stringlist
|
||||||
|
cmd.formats = 1
|
||||||
|
self.assertRaises(DistutilsOptionError, cmd.finalize_options)
|
||||||
|
cmd.formats = ['zip']
|
||||||
|
cmd.finalize_options()
|
||||||
|
|
||||||
|
# formats has to be known
|
||||||
|
cmd.formats = 'supazipa'
|
||||||
|
self.assertRaises(DistutilsOptionError, cmd.finalize_options)
|
||||||
|
|
||||||
|
|
||||||
def test_suite():
|
def test_suite():
|
||||||
return unittest.makeSuite(sdistTestCase)
|
return unittest.makeSuite(sdistTestCase)
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue