view tests/sanity.txt @ 76:b4fb27d126aa

tests work again \O/
author Jeff Hammel <jhammel@mozilla.com>
date Sun, 27 Jan 2013 21:43:41 -0800
parents 0f62570e80f3
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