summaryrefslogtreecommitdiffstats
path: root/Lib/packaging
diff options
context:
space:
mode:
authorÉric Araujo <merwok@netwok.org>2011-11-02 23:20:03 (GMT)
committerÉric Araujo <merwok@netwok.org>2011-11-02 23:20:03 (GMT)
commitdfd232898d4ae64a4c176ed492eec5e1ab209ef8 (patch)
tree503408f1e04f1e694787bb13672c7713e2ed9633 /Lib/packaging
parent9ad81a359101bff7bbfe9d126534bc8c9cfd606d (diff)
downloadcpython-dfd232898d4ae64a4c176ed492eec5e1ab209ef8.zip
cpython-dfd232898d4ae64a4c176ed492eec5e1ab209ef8.tar.gz
cpython-dfd232898d4ae64a4c176ed492eec5e1ab209ef8.tar.bz2
Minor code reorganization in one packaging test file
Diffstat (limited to 'Lib/packaging')
-rw-r--r--Lib/packaging/tests/test_command_sdist.py52
1 files changed, 25 insertions, 27 deletions
diff --git a/Lib/packaging/tests/test_command_sdist.py b/Lib/packaging/tests/test_command_sdist.py
index 7ea138c..34a2e9c 100644
--- 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 zipfile
import tarfile
-
-from packaging.tests.support import requires_zlib
+import zipfile
try:
import grp
@@ -12,16 +10,16 @@ try:
except ImportError:
UID_GID_SUPPORT = False
+from shutil import get_archive_formats
from os.path import join
-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.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.tests.support import requires_zlib
MANIFEST = """\
@@ -88,7 +86,6 @@ class SDistTestCase(support.TempdirManager,
# 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 @@ class SDistTestCase(support.TempdirManager,
# 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 @@ class SDistTestCase(support.TempdirManager,
self.assertEqual(len(output), num_formats)
def test_finalize_options(self):
-
dist, cmd = self.get_cmd()
cmd.finalize_options()
@@ -264,6 +262,18 @@ class SDistTestCase(support.TempdirManager,
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 @@ class SDistTestCase(support.TempdirManager,
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'