Commit d6c0aeb2 authored by Éric Araujo's avatar Éric Araujo

Fix determination of Metadata version (#8933). Patch by Filip Gruszczyński.

parent 4af2ac31
...@@ -1111,7 +1111,8 @@ class DistributionMetadata: ...@@ -1111,7 +1111,8 @@ class DistributionMetadata:
"""Write the PKG-INFO format data to a file object. """Write the PKG-INFO format data to a file object.
""" """
version = '1.0' version = '1.0'
if self.provides or self.requires or self.obsoletes: if (self.provides or self.requires or self.obsoletes or
self.classifiers or self.download_url):
version = '1.1' version = '1.1'
self._write_field(file, 'Metadata-Version', version) self._write_field(file, 'Metadata-Version', version)
......
...@@ -245,6 +245,20 @@ class MetadataTestCase(support.TempdirManager, support.EnvironGuard, ...@@ -245,6 +245,20 @@ class MetadataTestCase(support.TempdirManager, support.EnvironGuard,
sys.argv[:] = self.argv[1] sys.argv[:] = self.argv[1]
super(MetadataTestCase, self).tearDown() super(MetadataTestCase, self).tearDown()
def test_classifier(self):
attrs = {'name': 'Boa', 'version': '3.0',
'classifiers': ['Programming Language :: Python :: 3']}
dist = Distribution(attrs)
meta = self.format_metadata(dist)
self.assertIn('Metadata-Version: 1.1', meta)
def test_download_url(self):
attrs = {'name': 'Boa', 'version': '3.0',
'download_url': 'http://example.org/boa'}
dist = Distribution(attrs)
meta = self.format_metadata(dist)
self.assertIn('Metadata-Version: 1.1', meta)
def test_long_description(self): def test_long_description(self):
long_desc = textwrap.dedent("""\ long_desc = textwrap.dedent("""\
example:: example::
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment