2 # -*- coding: utf-8 -*-
5 # Author: David Goodger <goodger@python.org>
6 # Copyright: This module has been placed in the public domain.
9 Tests for docutils.transforms.frontmatter.DocInfo.
12 from __init__
import DocutilsTestSupport
13 from docutils
.transforms
.frontmatter
import DocInfo
14 from docutils
.parsers
.rst
import Parser
19 settings
= {'language_code': 'en'}
20 s
= DocutilsTestSupport
.TransformTestSuite(
21 parser
, suite_settings
=settings
)
22 s
.generateTests(totest
)
23 settings
['language_code'] = 'de'
24 s
.generateTests(totest_de
)
25 settings
['language_code'] = 'ru'
26 s
.generateTests(totest_ru
)
33 totest
['bibliographic_field_lists'] = ((DocInfo
,), [
35 .. Bibliographic element extraction.
38 There can only be one abstract.
40 It is automatically moved to the end of the other bibliographic elements.
48 <document source="test data">
56 <field classes="parameter-i">
62 <topic classes="abstract">
66 There can only be one abstract.
68 It is automatically moved to the end of the other bibliographic elements.
69 <comment xml:space="preserve">
70 Bibliographic element extraction.
73 .. Bibliographic element extraction.
75 :Abstract: Abstract 1.
77 :Address: 123 My Street
81 :Abstract: Abstract 2 (should generate a warning).
86 <document source="test data">
90 <address xml:space="preserve">
94 <reference refuri="mailto:me@my.org">
103 Abstract 2 (should generate a warning).
104 <system_message level="2" line="9" source="test data" type="WARNING">
106 There can only be one "Abstract" field.
109 <field classes="parameter-i">
115 <topic classes="abstract">
120 <comment xml:space="preserve">
121 Bibliographic element extraction.
124 :Author: - must be a paragraph
125 :Status: a *simple* paragraph
131 .. and not empty either
134 <document source="test data">
140 <bullet_list bullet="-">
144 <system_message level="2" line="1" source="test data" type="WARNING">
146 Cannot extract bibliographic field "Author" containing anything other than a single paragraph.
160 <system_message level="2" line="3" source="test data" type="WARNING">
162 Cannot extract compound bibliographic field "Date".
167 <system_message level="2" line="6" source="test data" type="WARNING">
169 Cannot extract empty bibliographic field "Version".
170 <comment xml:space="preserve">
174 :Authors: Me, Myself, **I**
175 :Authors: PacMan; Ms. PacMan; PacMan, Jr.
187 <document source="test data">
224 <document source="test data">
254 <document source="test data">
260 <system_message level="2" line="1" source="test data" type="WARNING">
262 Cannot extract empty bibliographic field "Authors".
267 <enumerated_list enumtype="arabic" prefix="" suffix=".">
274 <system_message level="2" line="3" source="test data" type="WARNING">
276 Bibliographic field "Authors" incompatible with extraction: it must contain either a single paragraph (with authors separated by one of ";,"), multiple paragraphs (one per author), or a bullet list with one paragraph (one author) per item.
281 <bullet_list bullet="-">
284 <system_message level="2" line="6" source="test data" type="WARNING">
286 Bibliographic field "Authors" incompatible with extraction: it must contain either a single paragraph (with authors separated by one of ";,"), multiple paragraphs (one per author), or a bullet list with one paragraph (one author) per item.
291 <bullet_list bullet="-">
297 <system_message level="2" line="10" source="test data" type="WARNING">
299 Bibliographic field "Authors" incompatible with extraction: it must contain either a single paragraph (with authors separated by one of ";,"), multiple paragraphs (one per author), or a bullet list with one paragraph (one author) per item.
304 <bullet_list bullet="-">
310 <system_message level="2" line="15" source="test data" type="WARNING">
312 Bibliographic field "Authors" incompatible with extraction: it must contain either a single paragraph (with authors separated by one of ";,"), multiple paragraphs (one per author), or a bullet list with one paragraph (one author) per item.
315 .. RCS keyword extraction.
317 :Status: (some text) $""" + """RCSfile: test_docinfo.py,v $ (more text)
318 :Date: (some text) $""" + """Date: 2002/10/08 01:34:23 $ (more text)
319 :Date: (some text) $""" + """Date: 2005-03-26T16:21:28.693201Z $ (more text)
320 :Version: (some text) $""" + """Revision: 1.1 $ (more text)
323 <document source="test data">
326 (some text) test_docinfo.py (more text)
328 (some text) 2002-10-08 (more text)
330 (some text) 2005-03-26 (more text)
332 (some text) 1.1 (more text)
333 <comment xml:space="preserve">
334 RCS keyword extraction.
338 totest_de
['bibliographic_field_lists'] = ((DocInfo
,), [
340 .. Bibliographic element extraction for a German document.
342 :Zusammenfassung: Abstract 1.
344 :Adresse: 123 My Street
349 :Parameter i: integer
352 <document source="test data">
356 <address xml:space="preserve">
360 <reference refuri="mailto:me@my.org">
366 <field classes="parameter-i">
372 <topic classes="abstract">
377 <comment xml:space="preserve">
378 Bibliographic element extraction for a German document.
381 totest_ru
['bibliographic_field_lists'] = ((DocInfo
,), [
383 .. Bibliographic element extraction for a Russian document.
385 :аннотация: Abstract 1.
387 :адрес: 123 My Street
392 :Parameter i: integer
395 <document source="test data">
399 <address xml:space="preserve">
403 <reference refuri="mailto:me@my.org">
409 <field classes="parameter-i">
415 <topic classes="abstract">
420 <comment xml:space="preserve">
421 Bibliographic element extraction for a Russian document.
425 if __name__
== '__main__':
427 unittest
.main(defaultTest
='suite')