Merged revisions 72618 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r72618 | tarek.ziade | 2009-05-14 14:40:59 +0200 (Thu, 14 May 2009) | 1 line
more test coverage for distutils sdist command
........
diff --git a/Lib/distutils/command/sdist.py b/Lib/distutils/command/sdist.py
index 1a64d0e..836b962 100644
--- a/Lib/distutils/command/sdist.py
+++ b/Lib/distutils/command/sdist.py
@@ -17,19 +17,18 @@
from distutils import log
from distutils.util import convert_path
-def show_formats ():
+def show_formats():
"""Print all possible values for the 'formats' option (used by
the "--help-formats" command-line option).
"""
from distutils.fancy_getopt import FancyGetopt
from distutils.archive_util import ARCHIVE_FORMATS
- formats=[]
+ formats = []
for format in ARCHIVE_FORMATS.keys():
formats.append(("formats=" + format, None,
ARCHIVE_FORMATS[format][2]))
formats.sort()
- pretty_printer = FancyGetopt(formats)
- pretty_printer.print_help(
+ FancyGetopt(formats).print_help(
"List of available source distribution formats:")
class sdist (Command):
diff --git a/Lib/distutils/tests/test_sdist.py b/Lib/distutils/tests/test_sdist.py
index 8af080f..ec95ffb 100644
--- a/Lib/distutils/tests/test_sdist.py
+++ b/Lib/distutils/tests/test_sdist.py
@@ -7,12 +7,16 @@
import sys
import tempfile
+from test.support import captured_stdout
+
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.spawn import find_executable
from distutils.tests import support
+from distutils.archive_util import ARCHIVE_FORMATS
SETUP_PY = """
from distutils.core import setup
@@ -210,6 +214,16 @@
manifest = open(join(self.tmp_dir, 'MANIFEST')).read()
self.assertEquals(manifest, MANIFEST % {'sep': os.sep})
+ def test_show_formats(self):
+ with captured_stdout() as stdout:
+ show_formats()
+
+ # the output should be a header line + one line per format
+ num_formats = len(ARCHIVE_FORMATS.keys())
+ output = [line for line in stdout.getvalue().split('\n')
+ if line.strip().startswith('--formats=')]
+ self.assertEquals(len(output), num_formats)
+
def test_suite():
return unittest.makeSuite(sdistTestCase)