3 from nose.tools import eq_, raises
9 <mediawiki xmlns="http://www.mediawiki.org/xml/export-0.8/"
10 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
11 xsi:schemaLocation="http://www.mediawiki.org/xml/export-0.8/
12 http://www.mediawiki.org/xml/export-0.8.xsd"
13 version="0.8" xml:lang="en">
15 <sitename>Wikipedia</sitename>
16 <base>http://en.wikipedia.org/wiki/Main_Page</base>
17 <generator>MediaWiki 1.22wmf2</generator>
18 <case>first-letter</case>
20 <namespace key="0" case="first-letter" />
21 <namespace key="1" case="first-letter">Talk</namespace>
30 <timestamp>2004-08-09T09:04:08Z</timestamp>
32 <username>Gen0cide</username>
35 <text xml:space="preserve">Revision 1 text</text>
36 <sha1>g9chqqg94myzq11c56ixvq7o1yg75n9</sha1>
37 <model>wikitext</model>
38 <format>text/x-wiki</format>
42 <timestamp>2004-08-10T09:04:08Z</timestamp>
44 <ip>222.152.210.109</ip>
46 <text xml:space="preserve">Revision 2 text</text>
47 <sha1>g9chqqg94myzq11c56ixvq7o1yg75n9</sha1>
48 <model>wikitext</model>
49 <comment>Comment 2</comment>
50 <format>text/x-wiki</format>
59 <timestamp>2004-08-11T09:04:08Z</timestamp>
61 <ip>222.152.210.22</ip>
63 <text xml:space="preserve">Revision 3 text</text>
64 <sha1>g9chqqg94myzq11c56ixvq7o1yg75n9</sha1>
65 <model>wikitext</model>
66 <format>text/x-wiki</format>
73 f = io.StringIO(SAMPLE_XML)
75 def process_dump(dump, path):
81 yield {'page_id': page.id, 'revisions': count}
84 for doc in map([f], process_dump):
85 page_id = doc['page_id']
86 revisions = doc['revisions']
99 def test_dict_yield():
101 f = io.StringIO(SAMPLE_XML)
103 def process_dump(dump, path):
109 yield {'page_id': page.id, 'revisions': count}
112 for doc in map([f], process_dump):
113 page_id = doc['page_id']
114 revisions = doc['revisions']
128 def test_map_error():
129 f = io.StringIO(SAMPLE_XML)
131 def process_dump(dump, path):
135 raise TypeError("Fake error")
138 for doc in map([f], process_dump):
139 page_id = doc['page_id']
142 def test_map_error_handler():
143 f = io.StringIO(SAMPLE_XML)
145 def process_dump(dump, path, handle_error=lambda exp, stack: None):
153 raise TypeError("Fake type error.")
155 yield {'page_id': page.id, 'revisions': count}
158 for doc in map([f], process_dump):
159 page_id = doc['page_id']
160 revisions = doc['revisions']