docutils.utils is now a package (providing a place for sub-modules)
[docutils.git] / test / test_parsers / test_rst / test_directives / test_code_long.py
blobf0153572690c86646cdd047e91f45a99d5909395
1 #! /usr/bin/env python
3 # $Id$
4 # Author: Guenter Milde
5 # Copyright: This module has been placed in the public domain.
7 """
8 Test the 'code' directive in body.py with syntax_highlight = 'long'.
9 """
11 from __init__ import DocutilsTestSupport
12 from docutils.utils.code_analyzer import with_pygments
14 def suite():
15 s = DocutilsTestSupport.ParserTestSuite(suite_settings={'syntax_highlight':'long'})
16 if with_pygments:
17 s.generateTests(totest)
18 return s
20 totest = {}
22 totest['code-parsing-long'] = [
23 ["""\
24 .. code:: python
25 :number-lines: 7
27 def my_function():
28 '''Test the lexer.
29 '''
31 # and now for something completely different
32 print 8/2
33 """,
34 """\
35 <document source="test data">
36 <literal_block classes="code python" xml:space="preserve">
37 <inline classes="ln">
38 7 \n\
39 <inline classes="keyword">
40 def
41 \n\
42 <inline classes="name function">
43 my_function
44 <inline classes="punctuation">
45 ():
46 \n\
47 <inline classes="ln">
48 8 \n\
49 \n\
50 <inline classes="literal string doc">
51 \'\'\'Test the lexer.
52 <inline classes="ln">
53 9 \n\
54 <inline classes="literal string doc">
55 \'\'\'
56 \n\
57 <inline classes="ln">
58 10 \n\
59 \n\
60 <inline classes="ln">
61 11 \n\
62 \n\
63 <inline classes="comment">
64 # and now for something completely different
65 \n\
66 <inline classes="ln">
67 12 \n\
68 \n\
69 <inline classes="keyword">
70 print
71 \n\
72 <inline classes="literal number integer">
74 <inline classes="operator">
76 <inline classes="literal number integer">
78 """],
79 ["""\
80 .. code:: latex
82 hello \emph{world} % emphasize
83 """,
84 """\
85 <document source="test data">
86 <literal_block classes="code latex" xml:space="preserve">
87 hello \n\
88 <inline classes="keyword">
89 \\emph
90 <inline classes="name builtin">
92 world
93 <inline classes="name builtin">
95 \n\
96 <inline classes="comment">
97 % emphasize"""],
101 if __name__ == '__main__':
102 import unittest
103 unittest.main(defaultTest='suite')