diff options
| author | Georg Brandl <georg@python.org> | 2008-11-30 21:09:28 +0100 |
|---|---|---|
| committer | Georg Brandl <georg@python.org> | 2008-11-30 21:09:28 +0100 |
| commit | aeca13f70a5275050d261945c570f7b60592a868 (patch) | |
| tree | 73c6d30c4760a5121a62a95d5511ecc171443475 /tests | |
| parent | ed6492a73f5452641dee0821ed54a607a03aad10 (diff) | |
| parent | dd7923740da5689eed6a56343c406550f99c5044 (diff) | |
| download | sphinx-aeca13f70a5275050d261945c570f7b60592a868.tar.gz | |
Merge bugfix from 0.5.
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/test_build.py | 2 | ||||
| -rw-r--r-- | tests/test_config.py | 4 | ||||
| -rw-r--r-- | tests/test_highlighting.py | 51 | ||||
| -rw-r--r-- | tests/test_markup.py | 4 |
4 files changed, 57 insertions, 4 deletions
diff --git a/tests/test_build.py b/tests/test_build.py index 938d3c98..410a4e14 100644 --- a/tests/test_build.py +++ b/tests/test_build.py @@ -20,7 +20,7 @@ from util import * from etree13 import ElementTree as ET from sphinx.builder import StandaloneHTMLBuilder, LaTeXBuilder -from sphinx.latexwriter import LaTeXTranslator +from sphinx.writers.latex import LaTeXTranslator html_warnfile = StringIO() diff --git a/tests/test_config.py b/tests/test_config.py index 57d1936b..53cba59c 100644 --- a/tests/test_config.py +++ b/tests/test_config.py @@ -15,7 +15,8 @@ from util import * from sphinx.application import ExtensionError -@with_app(confoverrides={'master_doc': 'master', 'nonexisting_value': 'True'}) +@with_app(confoverrides={'master_doc': 'master', 'nonexisting_value': 'True', + 'latex_elements.docclass': 'scrartcl'}) def test_core_config(app): cfg = app.config @@ -26,6 +27,7 @@ def test_core_config(app): # overrides assert cfg.master_doc == 'master' + assert cfg.latex_elements['docclass'] == 'scrartcl' # simple default values assert 'exclude_dirs' not in cfg.__dict__ diff --git a/tests/test_highlighting.py b/tests/test_highlighting.py new file mode 100644 index 00000000..067c37cb --- /dev/null +++ b/tests/test_highlighting.py @@ -0,0 +1,51 @@ +# -*- coding: utf-8 -*- +""" + test_highlighting + ~~~~~~~~~~~~~~~~~ + + Test the Pygments highlighting bridge. + + :copyright: 2008 by Georg Brandl. + :license: BSD. +""" + +from util import * + +from pygments.lexer import RegexLexer +from pygments.token import Text, Name +from pygments.formatters.html import HtmlFormatter + +from sphinx.highlighting import PygmentsBridge + + +class MyLexer(RegexLexer): + name = 'testlexer' + + tokens = { + 'root': [ + ('a', Name), + ('b', Text), + ], + } + +class MyFormatter(HtmlFormatter): + def format(self, tokensource, outfile): + outfile.write('test') + + +@with_app() +def test_add_lexer(app): + app.add_lexer('test', MyLexer()) + + bridge = PygmentsBridge('html') + ret = bridge.highlight_block('ab', 'test') + assert '<span class="n">a</span>b' in ret + +def test_set_formatter(): + PygmentsBridge.html_formatter = MyFormatter + try: + bridge = PygmentsBridge('html') + ret = bridge.highlight_block('foo', 'python') + assert ret == 'test' + finally: + PygmentsBridge.html_formatter = HtmlFormatter diff --git a/tests/test_markup.py b/tests/test_markup.py index f1125103..a4b7cf77 100644 --- a/tests/test_markup.py +++ b/tests/test_markup.py @@ -17,8 +17,8 @@ from docutils import frontend, utils, nodes from docutils.parsers import rst from sphinx import addnodes -from sphinx.htmlwriter import HTMLWriter, SmartyPantsHTMLTranslator -from sphinx.latexwriter import LaTeXWriter, LaTeXTranslator +from sphinx.writers.html import HTMLWriter, SmartyPantsHTMLTranslator +from sphinx.writers.latex import LaTeXWriter, LaTeXTranslator def setup_module(): global app, settings, parser |
