Mercurial > hg > PaInt
annotate tests/sanity.txt @ 81:4446cba4cee6
update CommandParser and docstring for it
author | Jeff Hammel <jhammel@mozilla.com> |
---|---|
date | Mon, 28 Jan 2013 19:57:30 -0800 |
parents | b4fb27d126aa |
children |
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 | 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 | 20 >>> pkginfo_dist.parse(buffer.getvalue()) |
21 >>> newattrs = dict([(i, getattr(pkginfo_dist, i)) for i in pkginfo_dist]) | |
22 >>> newattrs['name'] == 'name' | |
23 True | |
24 >>> newattrs['home_page'] == 'http://example.org' | |
25 True | |
26 | |
76 | 27 Convert to headers:: |
75 | 28 |
76 | 29 >>> header_dict = dict((attr_name, header_name) for header_name, attr_name, multiple in pkginfo_dist._getHeaderAttrs()) |
30 >>> info = dict((header_dict[key], value) for key, value in newattrs.items()) | |
31 >>> sorted(info.keys()) | |
32 ['Author', 'Author-email', 'Description', 'Home-Page', 'Keywords', 'License', 'Metadata-Version', 'Name', 'Platform', 'Summary', 'Supported-Platform', 'Version'] | |
33 >>> info['Name'] == 'name' | |
34 True | |
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 | |
36 True |