pep8-fied distutils.command.sdist + more tests

This commit is contained in:
Tarek Ziadé 2009-05-14 14:56:14 +00:00
parent 064a768101
commit 8953913cf5
2 changed files with 39 additions and 44 deletions

View file

@ -100,7 +100,6 @@ class sdist (Command):
self.archive_files = None
def finalize_options(self):
if self.manifest is None:
self.manifest = "MANIFEST"
@ -124,9 +123,7 @@ class sdist (Command):
if self.dist_dir is None:
self.dist_dir = "dist"
def run(self):
# 'filelist' contains the list of files that will make up the
# manifest
self.filelist = FileList()
@ -148,7 +145,6 @@ class sdist (Command):
# or zipfile, or whatever.
self.make_distribution()
def check_metadata(self):
"""Ensure that all required elements of meta-data (name, version,
URL, (author and author_email) or (maintainer and
@ -179,9 +175,6 @@ class sdist (Command):
"or (maintainer and maintainer_email) " +
"must be supplied")
# check_metadata ()
def get_file_list(self):
"""Figure out the list of files to include in the source
distribution, and put it in 'self.filelist'. This might involve
@ -189,7 +182,6 @@ class sdist (Command):
reading the manifest, or just using the default file set -- it all
depends on the user's options and the state of the filesystem.
"""
# If we have a manifest template, see if it's newer than the
# manifest; if so, we'll regenerate the manifest.
template_exists = os.path.isfile(self.template)
@ -249,9 +241,6 @@ class sdist (Command):
else:
self.read_manifest()
# get_file_list ()
def add_defaults(self):
"""Add all the default files to self.filelist:
- README or README.txt
@ -334,9 +323,6 @@ class sdist (Command):
build_scripts = self.get_finalized_command('build_scripts')
self.filelist.extend(build_scripts.get_source_files())
# add_defaults ()
def read_template(self):
"""Read and parse manifest template file named by self.template.
@ -364,9 +350,6 @@ class sdist (Command):
template.current_line,
msg))
# read_template ()
def prune_file_list(self):
"""Prune off branches that might slip into the file list as created
by 'read_template()', but really don't belong there:
@ -402,9 +385,6 @@ class sdist (Command):
(self.manifest, self.filelist.files),
"writing manifest file '%s'" % self.manifest)
# write_manifest ()
def read_manifest(self):
"""Read the manifest file (named by 'self.manifest') and use it to
fill in 'self.filelist', the list of files to include in the source
@ -421,9 +401,6 @@ class sdist (Command):
self.filelist.append(line)
manifest.close()
# read_manifest ()
def make_release_tree(self, base_dir, files):
"""Create the directory tree that will become the source
distribution archive. All directories implied by the filenames in
@ -466,8 +443,6 @@ class sdist (Command):
self.distribution.metadata.write_pkg_info(base_dir)
# make_release_tree ()
def make_distribution(self):
"""Create the source distribution(s). First, we create the release
tree with 'make_release_tree()'; then, we create all required
@ -502,5 +477,3 @@ class sdist (Command):
was run, or None if the command hasn't run yet.
"""
return self.archive_files
# class sdist

View file

@ -13,7 +13,7 @@ from distutils.command.sdist import sdist
from distutils.command.sdist import show_formats
from distutils.core import Distribution
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.tests import support
from distutils.archive_util import ARCHIVE_FORMATS
@ -224,6 +224,28 @@ class sdistTestCase(PyPIRCCommandTestCase):
if line.strip().startswith('--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():
return unittest.makeSuite(sdistTestCase)