[Python-checkins] cpython: Fix determination of Metadata version in packaging (#8933).

eric.araujo python-checkins at python.org
Mon Sep 12 17:42:18 CEST 2011


http://hg.python.org/cpython/rev/ca21a47b1ec2
changeset: 72350:ca21a47b1ec2
user: Éric Araujo <merwok at netwok.org>
date: Sat Sep 10 05:22:48 2011 +0200
summary:
 Fix determination of Metadata version in packaging (#8933).
Original patch by Filip Gruszczyński.
files:
 Lib/packaging/metadata.py | 3 ++-
 Lib/packaging/tests/test_metadata.py | 15 ++++++++++++++-
 Misc/NEWS | 6 +++---
 3 files changed, 19 insertions(+), 5 deletions(-)
diff --git a/Lib/packaging/metadata.py b/Lib/packaging/metadata.py
--- a/Lib/packaging/metadata.py
+++ b/Lib/packaging/metadata.py
@@ -61,7 +61,8 @@
 'License', 'Classifier', 'Download-URL', 'Obsoletes',
 'Provides', 'Requires')
 
-_314_MARKERS = ('Obsoletes', 'Provides', 'Requires')
+_314_MARKERS = ('Obsoletes', 'Provides', 'Requires', 'Classifier',
+ 'Download-URL')
 
 _345_FIELDS = ('Metadata-Version', 'Name', 'Version', 'Platform',
 'Supported-Platform', 'Summary', 'Description',
diff --git a/Lib/packaging/tests/test_metadata.py b/Lib/packaging/tests/test_metadata.py
--- a/Lib/packaging/tests/test_metadata.py
+++ b/Lib/packaging/tests/test_metadata.py
@@ -251,7 +251,11 @@
 self.assertNotIn('Obsoletes', metadata)
 
 metadata['Classifier'] = ['ok']
- self.assertEqual(metadata['Metadata-Version'], '1.2')
+ self.assertEqual(metadata['Metadata-Version'], '1.1')
+
+ metadata = Metadata()
+ metadata['Download-URL'] = 'ok'
+ self.assertEqual(metadata['Metadata-Version'], '1.1')
 
 metadata = Metadata()
 metadata['Obsoletes'] = 'ok'
@@ -269,6 +273,15 @@
 metadata['Version'] = '1'
 self.assertEqual(metadata['Metadata-Version'], '1.0')
 
+ # make sure the _best_version function works okay with
+ # non-conflicting fields from 1.1 and 1.2 (i.e. we want only the
+ # requires/requires-dist and co. pairs to cause a conflict, not all
+ # fields in _314_MARKERS)
+ metadata = Metadata()
+ metadata['Requires-Python'] = '3'
+ metadata['Classifier'] = ['Programming language :: Python :: 3']
+ self.assertEqual(metadata['Metadata-Version'], '1.2')
+
 PKG_INFO = os.path.join(os.path.dirname(__file__),
 'SETUPTOOLS-PKG-INFO')
 metadata = Metadata(PKG_INFO)
diff --git a/Misc/NEWS b/Misc/NEWS
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -274,9 +274,9 @@
 Library
 -------
 
-- Issue #8933: distutils' PKG-INFO files will now correctly report
- Metadata-Version: 1.1 instead of 1.0 if a Classifier or Download-URL field is
- present.
+- Issue #8933: distutils' PKG-INFO files and packaging's METADATA files will
+ now correctly report Metadata-Version: 1.1 instead of 1.0 if a Classifier or
+ Download-URL field is present.
 
 - Issue #12567: Add curses.unget_wch() function. Push a character so the next
 get_wch() will return it.
-- 
Repository URL: http://hg.python.org/cpython


More information about the Python-checkins mailing list

AltStyle によって変換されたページ (->オリジナル) /