annotate tests/sanity.txt @ 78:ab0620d3755b

docstring
author Jeff Hammel <jhammel@mozilla.com>
date Mon, 28 Jan 2013 18:45:52 -0800
parents b4fb27d126aa
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
74
84890934af1f start tests for third-party sanity check; first up setup() -> metadata conversion
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
1 Sanity Check
84890934af1f start tests for third-party sanity check; first up setup() -> metadata conversion
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
2 ============
84890934af1f start tests for third-party sanity check; first up setup() -> metadata conversion
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
3
84890934af1f start tests for third-party sanity check; first up setup() -> metadata conversion
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
4 Imports::
84890934af1f start tests for third-party sanity check; first up setup() -> metadata conversion
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
5
84890934af1f start tests for third-party sanity check; first up setup() -> metadata conversion
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
6 >>> import pkginfo
84890934af1f start tests for third-party sanity check; first up setup() -> metadata conversion
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
7 >>> from distutils.dist import Distribution
84890934af1f start tests for third-party sanity check; first up setup() -> metadata conversion
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
8 >>> from StringIO import StringIO
84890934af1f start tests for third-party sanity check; first up setup() -> metadata conversion
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
9
84890934af1f start tests for third-party sanity check; first up setup() -> metadata conversion
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
10 Representative metadata::
84890934af1f start tests for third-party sanity check; first up setup() -> metadata conversion
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
11
75
0f62570e80f3 add some failing tests
Jeff Hammel <jhammel@mozilla.com>
parents: 74
diff changeset
12 >>> attrs = dict(name='name', version='0.0', description='description', url='http://example.org')
74
84890934af1f start tests for third-party sanity check; first up setup() -> metadata conversion
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
13
84890934af1f start tests for third-party sanity check; first up setup() -> metadata conversion
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
14 Make a distribution::
84890934af1f start tests for third-party sanity check; first up setup() -> metadata conversion
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
15
84890934af1f start tests for third-party sanity check; first up setup() -> metadata conversion
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
16 >>> distribution = Distribution(attrs)
84890934af1f start tests for third-party sanity check; first up setup() -> metadata conversion
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
17 >>> buffer = StringIO()
84890934af1f start tests for third-party sanity check; first up setup() -> metadata conversion
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
18 >>> distribution.metadata.write_pkg_file(buffer)
84890934af1f start tests for third-party sanity check; first up setup() -> metadata conversion
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
19 >>> pkginfo_dist = pkginfo.Distribution()
75
0f62570e80f3 add some failing tests
Jeff Hammel <jhammel@mozilla.com>
parents: 74
diff changeset
20 >>> pkginfo_dist.parse(buffer.getvalue())
0f62570e80f3 add some failing tests
Jeff Hammel <jhammel@mozilla.com>
parents: 74
diff changeset
21 >>> newattrs = dict([(i, getattr(pkginfo_dist, i)) for i in pkginfo_dist])
0f62570e80f3 add some failing tests
Jeff Hammel <jhammel@mozilla.com>
parents: 74
diff changeset
22 >>> newattrs['name'] == 'name'
0f62570e80f3 add some failing tests
Jeff Hammel <jhammel@mozilla.com>
parents: 74
diff changeset
23 True
0f62570e80f3 add some failing tests
Jeff Hammel <jhammel@mozilla.com>
parents: 74
diff changeset
24 >>> newattrs['home_page'] == 'http://example.org'
0f62570e80f3 add some failing tests
Jeff Hammel <jhammel@mozilla.com>
parents: 74
diff changeset
25 True
0f62570e80f3 add some failing tests
Jeff Hammel <jhammel@mozilla.com>
parents: 74
diff changeset
26
76
b4fb27d126aa tests work again \O/
Jeff Hammel <jhammel@mozilla.com>
parents: 75
diff changeset
27 Convert to headers::
75
0f62570e80f3 add some failing tests
Jeff Hammel <jhammel@mozilla.com>
parents: 74
diff changeset
28
76
b4fb27d126aa tests work again \O/
Jeff Hammel <jhammel@mozilla.com>
parents: 75
diff changeset
29 >>> header_dict = dict((attr_name, header_name) for header_name, attr_name, multiple in pkginfo_dist._getHeaderAttrs())
b4fb27d126aa tests work again \O/
Jeff Hammel <jhammel@mozilla.com>
parents: 75
diff changeset
30 >>> info = dict((header_dict[key], value) for key, value in newattrs.items())
b4fb27d126aa tests work again \O/
Jeff Hammel <jhammel@mozilla.com>
parents: 75
diff changeset
31 >>> sorted(info.keys())
b4fb27d126aa tests work again \O/
Jeff Hammel <jhammel@mozilla.com>
parents: 75
diff changeset
32 ['Author', 'Author-email', 'Description', 'Home-Page', 'Keywords', 'License', 'Metadata-Version', 'Name', 'Platform', 'Summary', 'Supported-Platform', 'Version']
b4fb27d126aa tests work again \O/
Jeff Hammel <jhammel@mozilla.com>
parents: 75
diff changeset
33 >>> info['Name'] == 'name'
b4fb27d126aa tests work again \O/
Jeff Hammel <jhammel@mozilla.com>
parents: 75
diff changeset
34 True
b4fb27d126aa tests work again \O/
Jeff Hammel <jhammel@mozilla.com>
parents: 75
diff changeset
35 >>> 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
b4fb27d126aa tests work again \O/
Jeff Hammel <jhammel@mozilla.com>
parents: 75
diff changeset
36 True