4 # Author: David Goodger <goodger@python.org>
5 # Copyright: This module has been placed in the public domain.
8 Tests for the misc.py "date" directive.
11 from __init__
import DocutilsTestSupport
14 from docutils
.utils
.error_reporting
import locale_encoding
17 s
= DocutilsTestSupport
.ParserTestSuite()
18 s
.generateTests(totest
)
27 Today's date is |date|.
30 <document source="test data">
31 <substitution_definition names="date">
35 <substitution_reference refname="date">
38 """ % time
.strftime('%Y-%m-%d')],
40 .. |date| date:: %a, %d %b %Y
43 <document source="test data">
44 <substitution_definition names="date">
46 """ % time
.strftime('%a, %d %b %Y')],
51 <document source="test data">
52 <system_message level="3" line="1" source="test data" type="ERROR">
54 Invalid context: the "date" directive can only be used within a substitution definition.
55 <literal_block xml:space="preserve">
60 # some locales return non-ASCII characters for names of days or months
61 if locale_encoding
in ['utf8', 'utf-8', 'latin-1']:
62 totest
['decode date'] = [
64 .. |date| date:: t\xc3glich
67 <document source="test data">
68 <substitution_definition names="date">
73 if __name__
== '__main__':
75 unittest
.main(defaultTest
='suite')