Mercurial > hg > PaInt
annotate tests/sanity.txt @ 75:0f62570e80f3
add some failing tests
author | Jeff Hammel <jhammel@mozilla.com> |
---|---|
date | Sun, 27 Jan 2013 20:42:18 -0800 |
parents | 84890934af1f |
children | b4fb27d126aa |
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 |
75 | 6 >>> import email |
74
84890934af1f
start tests for third-party sanity check; first up setup() -> metadata conversion
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
7 >>> import pkginfo |
84890934af1f
start tests for third-party sanity check; first up setup() -> metadata conversion
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
8 >>> 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
|
9 >>> 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
|
10 |
84890934af1f
start tests for third-party sanity check; first up setup() -> metadata conversion
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
11 Representative metadata:: |
84890934af1f
start tests for third-party sanity check; first up setup() -> metadata conversion
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
12 |
75 | 13 >>> 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
|
14 |
84890934af1f
start tests for third-party sanity check; first up setup() -> metadata conversion
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
15 Make a distribution:: |
84890934af1f
start tests for third-party sanity check; first up setup() -> metadata conversion
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
16 |
84890934af1f
start tests for third-party sanity check; first up setup() -> metadata conversion
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
17 >>> distribution = Distribution(attrs) |
84890934af1f
start tests for third-party sanity check; first up setup() -> metadata conversion
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
18 >>> buffer = StringIO() |
84890934af1f
start tests for third-party sanity check; first up setup() -> metadata conversion
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
19 >>> 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
|
20 >>> pkginfo_dist = pkginfo.Distribution() |
75 | 21 >>> pkginfo_dist.parse(buffer.getvalue()) |
22 >>> newattrs = dict([(i, getattr(pkginfo_dist, i)) for i in pkginfo_dist]) | |
23 >>> newattrs['name'] == 'name' | |
24 True | |
25 >>> newattrs['home_page'] == 'http://example.org' | |
26 True | |
27 | |
28 Convert to email:: | |
29 | |
30 >>> message = email.message.Message() | |
31 >>> for key, value in newattrs.items(): | |
32 ... message[key] = value | |
33 >>> message.keys() | |
34 >>> message.items() |