mirror of
https://github.com/python/cpython.git
synced 2025-07-24 11:44:31 +00:00
Merged revisions 76702,76704 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk ........ r76702 | tarek.ziade | 2009-12-08 09:56:49 +0100 (Tue, 08 Dec 2009) | 1 line Issue #7457: added a read_pkg_file method to distutils.dist.DistributionMetadata so we can read back PKG-INFO files ........ r76704 | tarek.ziade | 2009-12-08 10:39:51 +0100 (Tue, 08 Dec 2009) | 1 line removed the usage of rfc822 in favor of email.message.Message ........
This commit is contained in:
parent
0b9293f28b
commit
b88a49607a
5 changed files with 150 additions and 18 deletions
|
@ -7,7 +7,7 @@ import unittest
|
|||
import warnings
|
||||
import textwrap
|
||||
|
||||
from distutils.dist import Distribution, fix_help_options
|
||||
from distutils.dist import Distribution, fix_help_options, DistributionMetadata
|
||||
from distutils.cmd import Command
|
||||
import distutils.dist
|
||||
|
||||
|
@ -369,6 +369,33 @@ class MetadataTestCase(support.TempdirManager, support.EnvironGuard,
|
|||
meta = meta.replace('\n' + 8 * ' ', '\n')
|
||||
self.assertTrue(long_desc in meta)
|
||||
|
||||
def test_read_metadata(self):
|
||||
attrs = {"name": "package",
|
||||
"version": "1.0",
|
||||
"long_description": "desc",
|
||||
"description": "xxx",
|
||||
"download_url": "http://example.com",
|
||||
"keywords": ['one', 'two'],
|
||||
"requires": ['foo']}
|
||||
|
||||
dist = Distribution(attrs)
|
||||
metadata = dist.metadata
|
||||
|
||||
# write it then reloads it
|
||||
PKG_INFO = io.StringIO()
|
||||
metadata.write_pkg_file(PKG_INFO)
|
||||
PKG_INFO.seek(0)
|
||||
metadata.read_pkg_file(PKG_INFO)
|
||||
|
||||
self.assertEquals(metadata.name, "package")
|
||||
self.assertEquals(metadata.version, "1.0")
|
||||
self.assertEquals(metadata.description, "xxx")
|
||||
self.assertEquals(metadata.download_url, 'http://example.com')
|
||||
self.assertEquals(metadata.keywords, ['one', 'two'])
|
||||
self.assertEquals(metadata.platforms, ['UNKNOWN'])
|
||||
self.assertEquals(metadata.obsoletes, None)
|
||||
self.assertEquals(metadata.requires, ['foo'])
|
||||
|
||||
def test_suite():
|
||||
suite = unittest.TestSuite()
|
||||
suite.addTest(unittest.makeSuite(DistributionTestCase))
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue