[Python-checkins] cpython: Minor code reorganization in one packaging test file
eric.araujo
python-checkins at python.org
Thu Nov 3 16:45:46 CET 2011
http://hg.python.org/cpython/rev/2cdb0063c854
changeset: 73317:2cdb0063c854
user: Éric Araujo <merwok at netwok.org>
date: Thu Nov 03 00:20:03 2011 +0100
summary:
Minor code reorganization in one packaging test file
files:
Lib/packaging/tests/test_command_sdist.py | 54 +++++-----
1 files changed, 26 insertions(+), 28 deletions(-)
diff --git a/Lib/packaging/tests/test_command_sdist.py b/Lib/packaging/tests/test_command_sdist.py
--- a/Lib/packaging/tests/test_command_sdist.py
+++ b/Lib/packaging/tests/test_command_sdist.py
@@ -1,9 +1,7 @@
"""Tests for packaging.command.sdist."""
import os
+import tarfile
import zipfile
-import tarfile
-
-from packaging.tests.support import requires_zlib
try:
import grp
@@ -12,16 +10,16 @@
except ImportError:
UID_GID_SUPPORT = False
+from shutil import get_archive_formats
from os.path import join
+from packaging.dist import Distribution
+from packaging.util import find_executable
+from packaging.errors import PackagingOptionError
+from packaging.command.sdist import sdist, show_formats
+
+from packaging.tests import support, unittest
from packaging.tests import captured_stdout
-from packaging.command.sdist import sdist
-from packaging.command.sdist import show_formats
-from packaging.dist import Distribution
-from packaging.tests import unittest
-from packaging.errors import PackagingOptionError
-from packaging.util import find_executable
-from packaging.tests import support
-from shutil import get_archive_formats
+from packaging.tests.support import requires_zlib
MANIFEST = """\
@@ -88,7 +86,6 @@
# creating VCS directories with some files in them
os.mkdir(join(self.tmp_dir, 'somecode', '.svn'))
-
self.write_file((self.tmp_dir, 'somecode', '.svn', 'ok.py'), 'xxx')
os.mkdir(join(self.tmp_dir, 'somecode', '.hg'))
@@ -216,12 +213,14 @@
# testing the `check-metadata` option
dist, cmd = self.get_cmd(metadata={'name': 'xxx', 'version': 'xxx'})
- # this should raise some warnings
- # with the check subcommand
+ # this should cause the check subcommand to log two warnings:
+ # version is invalid, home-page and author are missing
cmd.ensure_finalized()
cmd.run()
warnings = self.get_logs()
- self.assertEqual(len(warnings), 4)
+ check_warnings = [msg for msg in warnings if
+ not msg.startswith('sdist:')]
+ self.assertEqual(len(check_warnings), 2, warnings)
# trying with a complete set of metadata
self.loghandler.flush()
@@ -244,7 +243,6 @@
self.assertEqual(len(output), num_formats)
def test_finalize_options(self):
-
dist, cmd = self.get_cmd()
cmd.finalize_options()
@@ -264,6 +262,18 @@
self.assertRaises(PackagingOptionError, cmd.finalize_options)
@requires_zlib
+ def test_template(self):
+ dist, cmd = self.get_cmd()
+ dist.extra_files = ['include yeah']
+ cmd.ensure_finalized()
+ self.write_file((self.tmp_dir, 'yeah'), 'xxx')
+ cmd.run()
+ with open(cmd.manifest) as f:
+ content = f.read()
+
+ self.assertIn('yeah', content)
+
+ @requires_zlib
@unittest.skipUnless(UID_GID_SUPPORT, "requires grp and pwd support")
@unittest.skipIf(find_executable('tar') is None or
find_executable('gzip') is None,
@@ -368,18 +378,6 @@
self.assertEqual(manifest, ['README.manual'])
@requires_zlib
- def test_template(self):
- dist, cmd = self.get_cmd()
- dist.extra_files = ['include yeah']
- cmd.ensure_finalized()
- self.write_file((self.tmp_dir, 'yeah'), 'xxx')
- cmd.run()
- with open(cmd.manifest) as f:
- content = f.read()
-
- self.assertIn('yeah', content)
-
- @requires_zlib
def test_manifest_builder(self):
dist, cmd = self.get_cmd()
cmd.manifest_builders = 'packaging.tests.test_command_sdist.builder'
--
Repository URL: http://hg.python.org/cpython
More information about the Python-checkins
mailing list