[Python-checkins] distutils2: Get back things lost in a recent merge
tarek.ziade
python-checkins at python.org
Thu Jul 15 01:38:05 CEST 2010
tarek.ziade pushed 2a9ad83361f7 to distutils2:
http://hg.python.org/distutils2/rev/2a9ad83361f7
changeset: 360:2a9ad83361f7
user: ?ric Araujo <merwok at netwok.org>
date: Wed Jul 07 20:19:08 2010 +0200
summary: Get back things lost in a recent merge
files: docs/source/metadata.rst, src/distutils2/_backport/tests/test_pkgutil.py, src/distutils2/tests/test_upload.py, src/setup.py
diff --git a/docs/source/metadata.rst b/docs/source/metadata.rst
--- a/docs/source/metadata.rst
+++ b/docs/source/metadata.rst
@@ -17,7 +17,7 @@
Reading metadata
================
-The :class:`DistributionMetadata` class can be instanciated with the path of
+The :class:`DistributionMetadata` class can be instantiated with the path of
the metadata file, and provides a dict-like interface to the values::
>>> from distutils2.metadata import DistributionMetadata
@@ -32,14 +32,14 @@
["pywin32; sys.platform == 'win32'", "Sphinx"]
The fields that supports environment markers can be automatically ignored if
-the object is instanciated using the ``platform_dependant`` option.
+the object is instantiated using the ``platform_dependent`` option.
:class:`DistributionMetadata` will interpret in the case the markers and will
automatically remove the fields that are not compliant with the running
environment. Here's an example under Mac OS X. The win32 dependency
we saw earlier is ignored::
>>> from distutils2.metadata import DistributionMetadata
- >>> metadata = DistributionMetadata('PKG-INFO', platform_dependant=True)
+ >>> metadata = DistributionMetadata('PKG-INFO', platform_dependent=True)
>>> metadata['Requires-Dist']
['bar']
@@ -53,7 +53,7 @@
>>> from distutils2.metadata import DistributionMetadata
>>> context = {'sys.platform': 'win32'}
- >>> metadata = DistributionMetadata('PKG-INFO', platform_dependant=True,
+ >>> metadata = DistributionMetadata('PKG-INFO', platform_dependent=True,
... execution_context=context)
...
>>> metadata['Requires-Dist'] = ["pywin32; sys.platform == 'win32'",
@@ -71,7 +71,7 @@
>>> metadata.write('/to/my/PKG-INFO')
The class will pick the best version for the metadata, depending on the values
-provided. If all the values provided exists in all versions, the class will
+provided. If all the values provided exist in all versions, the class will
use :attr:`metadata.PKG_INFO_PREFERRED_VERSION`. It is set by default to 1.0.
@@ -79,7 +79,7 @@
==================================
Some fields in :pep:`345` have to follow a version scheme in their versions
-predicate. When the scheme is violated, a warning is emited::
+predicate. When the scheme is violated, a warning is emitted::
>>> from distutils2.metadata import DistributionMetadata
>>> metadata = DistributionMetadata()
@@ -90,6 +90,3 @@
.. TODO talk about check()
-
-
-
diff --git a/src/distutils2/_backport/tests/test_pkgutil.py b/src/distutils2/_backport/tests/test_pkgutil.py
--- a/src/distutils2/_backport/tests/test_pkgutil.py
+++ b/src/distutils2/_backport/tests/test_pkgutil.py
@@ -13,9 +13,9 @@
from md5 import md5
from test.test_support import run_unittest, TESTFN
+from distutils2.tests.support import unittest
from distutils2._backport import pkgutil
-from distutils2.tests.support import unittest
try:
from os.path import relpath
@@ -34,10 +34,12 @@
class TestPkgUtilData(unittest.TestCase):
def setUp(self):
+ super(TestPkgUtilData, self).setUp()
self.dirname = tempfile.mkdtemp()
sys.path.insert(0, self.dirname)
def tearDown(self):
+ super(TestPkgUtilData, self).tearDown()
del sys.path[0]
shutil.rmtree(self.dirname)
@@ -52,15 +54,22 @@
os.mkdir(package_dir)
# Empty init.py
f = open(os.path.join(package_dir, '__init__.py'), "wb")
- f.close()
+ try:
+ pass
+ finally:
+ f.close()
# Resource files, res.txt, sub/res.txt
f = open(os.path.join(package_dir, 'res.txt'), "wb")
- f.write(RESOURCE_DATA)
- f.close()
+ try:
+ f.write(RESOURCE_DATA)
+ finally:
+ f.close()
os.mkdir(os.path.join(package_dir, 'sub'))
f = open(os.path.join(package_dir, 'sub', 'res.txt'), "wb")
- f.write(RESOURCE_DATA)
- f.close()
+ try:
+ f.write(RESOURCE_DATA)
+ finally:
+ f.close()
# Check we can read the resources
res1 = pkgutil.get_data(pkg, 'res.txt')
@@ -80,13 +89,14 @@
# Make a package with some resources
zip_file = os.path.join(self.dirname, zip)
z = zipfile.ZipFile(zip_file, 'w')
-
- # Empty init.py
- z.writestr(pkg + '/__init__.py', "")
- # Resource files, res.txt, sub/res.txt
- z.writestr(pkg + '/res.txt', RESOURCE_DATA)
- z.writestr(pkg + '/sub/res.txt', RESOURCE_DATA)
- z.close()
+ try:
+ # Empty init.py
+ z.writestr(pkg + '/__init__.py', "")
+ # Resource files, res.txt, sub/res.txt
+ z.writestr(pkg + '/res.txt', RESOURCE_DATA)
+ z.writestr(pkg + '/sub/res.txt', RESOURCE_DATA)
+ finally:
+ z.close()
# Check we can read the resources
sys.path.insert(0, zip_file)
@@ -121,10 +131,12 @@
return TestPkgUtilPEP302.MyTestLoader()
def setUp(self):
+ super(TestPkgUtilPEP302, self).setUp()
sys.meta_path.insert(0, self.MyTestImporter())
def tearDown(self):
del sys.meta_path[0]
+ super(TestPkgUtilPEP302, self).tearDown()
def test_getdata_pep302(self):
# Use a dummy importer/loader
@@ -146,6 +158,7 @@
# Tests the pkgutil.Distribution class
def setUp(self):
+ super(TestPkgUtilDistribution, self).setUp()
self.fake_dists_path = os.path.abspath(
os.path.join(os.path.dirname(__file__), 'fake_dists'))
@@ -194,6 +207,7 @@
for distinfo_dir in self.distinfo_dirs:
record_file = os.path.join(distinfo_dir, 'RECORD')
open(record_file, 'w').close()
+ super(TestPkgUtilDistribution, self).tearDown()
def test_instantiation(self):
# Test the Distribution class's instantiation provides us with usable
@@ -300,6 +314,7 @@
# Tests for the new functionality added in PEP 376.
def setUp(self):
+ super(TestPkgUtilPEP376, self).setUp()
# Setup the path environment with our fake distributions
current_path = os.path.abspath(os.path.dirname(__file__))
self.sys_path = sys.path[:]
@@ -308,6 +323,7 @@
def tearDown(self):
sys.path[:] = self.sys_path
+ super(TestPkgUtilPEP376, self).tearDown()
def test_distinfo_dirname(self):
# Given a name and a version, we expect the distinfo_dirname function
diff --git a/src/distutils2/tests/test_upload.py b/src/distutils2/tests/test_upload.py
--- a/src/distutils2/tests/test_upload.py
+++ b/src/distutils2/tests/test_upload.py
@@ -1,12 +1,13 @@
"""Tests for distutils.command.upload."""
# -*- encoding: utf8 -*-
-import os, sys
+import os
+import sys
from distutils2.command.upload import upload
from distutils2.core import Distribution
+from distutils2.tests import support
from distutils2.tests.pypi_server import PyPIServer, PyPIServerTestCase
-from distutils2.tests import support
from distutils2.tests.support import unittest
from distutils2.tests.test_config import PYPIRC, PyPIRCCommandTestCase
@@ -29,10 +30,10 @@
dist = Distribution()
cmd = upload(dist)
cmd.finalize_options()
- for attr, waited in (('username', 'me'), ('password', 'secret'),
- ('realm', 'pypi'),
- ('repository', 'http://pypi.python.org/pypi')):
- self.assertEqual(getattr(cmd, attr), waited)
+ for attr, expected in (('username', 'me'), ('password', 'secret'),
+ ('realm', 'pypi'),
+ ('repository', 'http://pypi.python.org/pypi')):
+ self.assertEqual(getattr(cmd, attr), expected)
def test_saved_password(self):
# file with no password
diff --git a/src/setup.py b/src/setup.py
--- a/src/setup.py
+++ b/src/setup.py
@@ -226,7 +226,7 @@
packages=find_packages(),
cmdclass={'sdist': sdist_hg, 'install': install_hg},
package_data={'distutils2._backport': ['sysconfig.cfg']},
- project_url=[('Mailing-list',
+ project_url=[('Mailing list',
'http://mail.python.org/mailman/listinfo/distutils-sig/'),
('Documentation',
'http://packages.python.org/Distutils2'),
--
Repository URL: http://hg.python.org/distutils2
More information about the Python-checkins
mailing list