More generator tests.

This commit is contained in:
Georg Brandl 2009-02-21 17:16:56 +01:00
parent 7073a5bd2c
commit 2ba9ec3456

View File

@ -80,39 +80,39 @@ def test_inline():
# correct interpretation of code with whitespace # correct interpretation of code with whitespace
_html = ('<p><tt class="docutils literal"><span class="pre">' _html = ('<p><tt class="docutils literal"><span class="pre">'
'code</span>&nbsp;&nbsp; <span class="pre">sample</span></tt></p>') 'code</span>&nbsp;&nbsp; <span class="pre">sample</span></tt></p>')
verify('``code sample``', _html, '\\code{code sample}') yield verify, '``code sample``', _html, '\\code{code sample}'
verify(':samp:`code sample`', _html, '\\samp{code sample}') yield verify, ':samp:`code sample`', _html, '\\samp{code sample}'
# interpolation of braces in samp and file roles (HTML only) # interpolation of braces in samp and file roles (HTML only)
verify(':samp:`a{b}c`', yield (verify, ':samp:`a{b}c`',
'<p><tt class="docutils literal"><span class="pre">a</span>' '<p><tt class="docutils literal"><span class="pre">a</span>'
'<em><span class="pre">b</span></em>' '<em><span class="pre">b</span></em>'
'<span class="pre">c</span></tt></p>', '<span class="pre">c</span></tt></p>',
'\\samp{abc}') '\\samp{abc}')
# interpolation of arrows in menuselection # interpolation of arrows in menuselection
verify(':menuselection:`a --> b`', yield (verify, ':menuselection:`a --> b`',
u'<p><em>a \N{TRIANGULAR BULLET} b</em></p>', u'<p><em>a \N{TRIANGULAR BULLET} b</em></p>',
'\\emph{a \\(\\rightarrow\\) b}') '\\emph{a \\(\\rightarrow\\) b}')
# non-interpolation of dashes in option role # non-interpolation of dashes in option role
verify_re(':option:`--with-option`', yield (verify_re, ':option:`--with-option`',
'<p><em( class="xref")?>--with-option</em></p>$', '<p><em( class="xref")?>--with-option</em></p>$',
r'\\emph{\\texttt{-{-}with-option}}$') r'\\emph{\\texttt{-{-}with-option}}$')
# verify smarty-pants quotes # verify smarty-pants quotes
verify('"John"', '<p>&#8220;John&#8221;</p>', "``John''") yield verify, '"John"', '<p>&#8220;John&#8221;</p>', "``John''"
# ... but not in literal text # ... but not in literal text
verify('``"John"``', yield (verify, '``"John"``',
'<p><tt class="docutils literal"><span class="pre">' '<p><tt class="docutils literal"><span class="pre">'
'&quot;John&quot;</span></tt></p>', '&quot;John&quot;</span></tt></p>',
'\\code{"John"}') '\\code{"John"}')
def test_latex_escaping(): def test_latex_escaping():
# correct escaping in normal mode # correct escaping in normal mode
verify(u'Γ\\\\∞$', None, ur'\(\Gamma\)\textbackslash{}\(\infty\)\$') yield verify, u'Γ\\\\∞$', None, ur'\(\Gamma\)\textbackslash{}\(\infty\)\$'
# in verbatim code fragments # in verbatim code fragments
verify(u'::\n\n\\∞$[]', None, yield (verify, u'::\n\n\\∞$[]', None,
u'\\begin{Verbatim}[commandchars=@\\[\\]]\n' u'\\begin{Verbatim}[commandchars=@\\[\\]]\n'
u'@PYGZat[]@(@Gamma@)\\@(@infty@)@$@PYGZlb[]@PYGZrb[]\n' u'@PYGZat[]@(@Gamma@)\\@(@infty@)@$@PYGZlb[]@PYGZrb[]\n'
u'\\end{Verbatim}') u'\\end{Verbatim}')