[Python-checkins] r65377 - doctools/branches/0.4.x/tests/test_markup.py
georg.brandl
python-checkins at python.org
Fri Aug 1 21:48:24 CEST 2008
Author: georg.brandl
Date: Fri Aug 1 21:48:24 2008
New Revision: 65377
Log:
Allow REs in markup checks.
Modified:
doctools/branches/0.4.x/tests/test_markup.py
Modified: doctools/branches/0.4.x/tests/test_markup.py
==============================================================================
--- doctools/branches/0.4.x/tests/test_markup.py (original)
+++ doctools/branches/0.4.x/tests/test_markup.py Fri Aug 1 21:48:24 2008
@@ -9,6 +9,8 @@
:license: BSD.
"""
+import re
+
from util import *
from docutils import frontend, utils, nodes
@@ -43,7 +45,7 @@
pass
-def verify(rst, html_expected, latex_expected):
+def verify_re(rst, html_expected, latex_expected):
document = utils.new_document('test data', settings)
parser.parse(rst, document)
for msg in document.traverse(nodes.system_message):
@@ -54,14 +56,17 @@
html_translator = ForgivingHTMLTranslator(app.builder, document)
document.walkabout(html_translator)
html_translated = ''.join(html_translator.fragment).strip()
- assert html_translated == html_expected, 'from' + rst
+ assert re.match(html_expected, html_translated), 'from' + rst
if latex_expected:
latex_translator = ForgivingLaTeXTranslator(document, app.builder)
latex_translator.first_document = -1 # don't write \begin{document}
document.walkabout(latex_translator)
latex_translated = ''.join(latex_translator.body).strip()
- assert latex_translated == latex_expected, 'from ' + rst
+ assert re.match(latex_expected, latex_translated), 'from ' + rst
+
+def verify(rst, html_expected, latex_expected):
+ verify_re(rst, re.escape(html_expected) + '$', re.escape(latex_expected) + '$')
def test_inline():
@@ -83,9 +88,9 @@
'\\emph{a $\\rightarrow$ b}')
# non-interpolation of dashes in option role
- verify(':option:`--with-option`',
- '<p><em class="xref">--with-option</em></p>',
- r'\emph{\texttt{--with-option}}')
+ verify_re(':option:`--with-option`',
+ '<p><em( class="xref")?>--with-option</em></p>$',
+ r'\\emph{\\texttt{--with-option}}$')
# verify smarty-pants quotes
verify('"John"', '<p>“John”</p>', "``John''")
More information about the Python-checkins
mailing list