[Python-checkins] distutils2: Minor assorted cleanups.
eric.araujo
python-checkins at python.org
Mon Nov 14 15:24:07 CET 2011
http://hg.python.org/distutils2/rev/b65e794099e3
changeset: 1241:b65e794099e3
user: Éric Araujo <merwok at netwok.org>
date: Sat Nov 12 04:29:11 2011 +0100
summary:
Minor assorted cleanups.
- Remove __main__ blocks obsoleted by pysetup
- Fix typo “seperate”
- Add one test that was promised but not written
- Reorganize one file
files:
distutils2/command/build.py | 2 +-
distutils2/create.py | 4 -
distutils2/depgraph.py | 5 +-
distutils2/dist.py | 2 +-
distutils2/install.py | 9 -
distutils2/tests/test_command_bdist_dumb.py | 17 ++-
distutils2/tests/test_command_register.py | 1 +
distutils2/tests/test_command_sdist.py | 47 ++++-----
8 files changed, 39 insertions(+), 48 deletions(-)
diff --git a/distutils2/command/build.py b/distutils2/command/build.py
--- a/distutils2/command/build.py
+++ b/distutils2/command/build.py
@@ -41,7 +41,7 @@
('use-2to3', None,
"use 2to3 to make source python 3.x compatible"),
('convert-2to3-doctests', None,
- "use 2to3 to convert doctests in seperate text files"),
+ "use 2to3 to convert doctests in separate text files"),
('use-2to3-fixers', None,
"list additional fixers opted for during 2to3 conversion"),
]
diff --git a/distutils2/create.py b/distutils2/create.py
--- a/distutils2/create.py
+++ b/distutils2/create.py
@@ -698,7 +698,3 @@
# program.write_setup_script()
# distutils2.util.cfg_to_args()
program()
-
-
-if __name__ == '__main__':
- main()
diff --git a/distutils2/depgraph.py b/distutils2/depgraph.py
--- a/distutils2/depgraph.py
+++ b/distutils2/depgraph.py
@@ -224,6 +224,7 @@
def main():
+ # XXX move to run._graph
from distutils2.database import get_distributions
tempout = StringIO()
try:
@@ -270,7 +271,3 @@
else:
print 'Supported option: -d [filename]'
sys.exit(1)
-
-
-if __name__ == '__main__':
- main()
diff --git a/distutils2/dist.py b/distutils2/dist.py
--- a/distutils2/dist.py
+++ b/distutils2/dist.py
@@ -69,7 +69,7 @@
('use-2to3', None,
"use 2to3 to make source python 3.x compatible"),
('convert-2to3-doctests', None,
- "use 2to3 to convert doctests in seperate text files"),
+ "use 2to3 to convert doctests in separate text files"),
]
display_option_names = [x[0].replace('-', '_') for x in display_options]
diff --git a/distutils2/install.py b/distutils2/install.py
--- a/distutils2/install.py
+++ b/distutils2/install.py
@@ -531,12 +531,3 @@
logger.info('%r conflicts with %s', project, ','.join(projects))
return True
-
-
-def _main(**attrs):
- if 'script_args' not in attrs:
- attrs['requirements'] = sys.argv[1]
- get_infos(**attrs)
-
-if __name__ == '__main__':
- _main()
diff --git a/distutils2/tests/test_command_bdist_dumb.py b/distutils2/tests/test_command_bdist_dumb.py
--- a/distutils2/tests/test_command_bdist_dumb.py
+++ b/distutils2/tests/test_command_bdist_dumb.py
@@ -1,6 +1,7 @@
"""Tests for distutils.command.bdist_dumb."""
import os
+import zipfile
import distutils2.util
from distutils2.dist import Distribution
@@ -49,15 +50,23 @@
# see what we have
dist_created = os.listdir(os.path.join(pkg_dir, 'dist'))
- base = "%s.%s" % (dist.get_fullname(), cmd.plat_name)
+ base = "%s.%s.zip" % (dist.get_fullname(), cmd.plat_name)
if os.name == 'os2':
base = base.replace(':', '-')
- wanted = ['%s.zip' % base]
- self.assertEqual(dist_created, wanted)
+ self.assertEqual(dist_created, [base])
# now let's check what we have in the zip file
- # XXX to be done
+ fp = zipfile.ZipFile(os.path.join('dist', base))
+ try:
+ contents = fp.namelist()
+ finally:
+ fp.close()
+
+ contents = sorted(os.path.basename(fn) for fn in contents)
+ wanted = ['foo.py', 'foo.pyc',
+ 'METADATA', 'INSTALLER', 'REQUESTED', 'RECORD']
+ self.assertEqual(contents, sorted(wanted))
def test_finalize_options(self):
pkg_dir, dist = self.create_dist()
diff --git a/distutils2/tests/test_command_register.py b/distutils2/tests/test_command_register.py
--- a/distutils2/tests/test_command_register.py
+++ b/distutils2/tests/test_command_register.py
@@ -144,6 +144,7 @@
register_module.input = _no_way
cmd.show_response = True
+ cmd.finalized = False
cmd.ensure_finalized()
cmd.run()
diff --git a/distutils2/tests/test_command_sdist.py b/distutils2/tests/test_command_sdist.py
--- a/distutils2/tests/test_command_sdist.py
+++ b/distutils2/tests/test_command_sdist.py
@@ -2,8 +2,6 @@
import os
import zipfile
-from distutils2.tests.support import requires_zlib
-
try:
import grp
import pwd
@@ -12,17 +10,17 @@
UID_GID_SUPPORT = False
from os.path import join
-from distutils2.tests import captured_stdout
-from distutils2.command.sdist import sdist
-from distutils2.command.sdist import show_formats
from distutils2.dist import Distribution
-from distutils2.tests import unittest
+from distutils2.util import find_executable
from distutils2.errors import PackagingOptionError
-from distutils2.util import find_executable
-from distutils2.tests import support
+from distutils2.command.sdist import sdist, show_formats
from distutils2._backport import tarfile
from distutils2._backport.shutil import get_archive_formats
+from distutils2.tests import support, unittest
+from distutils2.tests import captured_stdout
+from distutils2.tests.support import requires_zlib
+
MANIFEST = """\
# file GENERATED by distutils2, do NOT edit
@@ -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'))
@@ -146,7 +143,7 @@
# now trying a tar then a gztar
cmd.formats = ['tar', 'gztar']
-
+ cmd.finalized = False
cmd.ensure_finalized()
cmd.run()
@@ -274,6 +271,21 @@
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()
+ f = open(cmd.manifest)
+ try:
+ content = f.read()
+ finally:
+ f.close()
+
+ 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,
@@ -395,21 +407,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()
- f = open(cmd.manifest)
- try:
- content = f.read()
- finally:
- f.close()
-
- self.assertIn('yeah', content)
-
- @requires_zlib
def test_manifest_builder(self):
dist, cmd = self.get_cmd()
cmd.manifest_builders = 'distutils2.tests.test_command_sdist.builder'
--
Repository URL: http://hg.python.org/distutils2
More information about the Python-checkins
mailing list