diff options
| author | Georg Brandl <georg@python.org> | 2008-12-15 12:33:24 +0100 |
|---|---|---|
| committer | Georg Brandl <georg@python.org> | 2008-12-15 12:33:24 +0100 |
| commit | 3fe753f5452ff23031f3bc6440281a02bb83309d (patch) | |
| tree | d4ecba05a05e08be1fa4199ba1b464b9b1311642 /tests | |
| parent | 40b04a4ba7718c55d6882b50762d0c7442e30b5d (diff) | |
| parent | c0ee529e88d68c1564b96b525c8ec225a1525282 (diff) | |
| download | sphinx-3fe753f5452ff23031f3bc6440281a02bb83309d.tar.gz | |
Merge in 0.5 bugfixes.
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 b48cccc3..ea83e2e7 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 |
