Mercurial > hg > PaInt
view tests/sanity.txt @ 84:582ffe5e39a0
paint/package.py
author | Jeff Hammel <jhammel@mozilla.com> |
---|---|
date | Tue, 17 Sep 2013 17:46:51 -0700 |
parents | b4fb27d126aa |
children |
line wrap: on
line source
Sanity Check ============ Imports:: >>> import pkginfo >>> from distutils.dist import Distribution >>> from StringIO import StringIO Representative metadata:: >>> attrs = dict(name='name', version='0.0', description='description', url='http://example.org') Make a distribution:: >>> distribution = Distribution(attrs) >>> buffer = StringIO() >>> distribution.metadata.write_pkg_file(buffer) >>> pkginfo_dist = pkginfo.Distribution() >>> pkginfo_dist.parse(buffer.getvalue()) >>> newattrs = dict([(i, getattr(pkginfo_dist, i)) for i in pkginfo_dist]) >>> newattrs['name'] == 'name' True >>> newattrs['home_page'] == 'http://example.org' True Convert to headers:: >>> header_dict = dict((attr_name, header_name) for header_name, attr_name, multiple in pkginfo_dist._getHeaderAttrs()) >>> info = dict((header_dict[key], value) for key, value in newattrs.items()) >>> sorted(info.keys()) ['Author', 'Author-email', 'Description', 'Home-Page', 'Keywords', 'License', 'Metadata-Version', 'Name', 'Platform', 'Summary', 'Supported-Platform', 'Version'] >>> info['Name'] == 'name' True >>> info['Home-Page'] == 'http://example.org' # it should actually be Home-page: http://svn.python.org/projects/peps/trunk/pep-0314.txt, bug in pkginfo True