diff options
author | shimizukawa <shimizukawa@gmail.com> | 2013-02-05 23:57:26 +0900 |
---|---|---|
committer | shimizukawa <shimizukawa@gmail.com> | 2013-02-05 23:57:26 +0900 |
commit | 32a005fe1a5d16c6005e5d2dc14183b25583aa6b (patch) | |
tree | 891ade30fd110c0bbb35490d485e666c4b734390 /tests/test_build_text.py | |
parent | 3615546756dc7378d4ea21aed0a52046b1e2cdbe (diff) | |
download | sphinx-32a005fe1a5d16c6005e5d2dc14183b25583aa6b.tar.gz |
Fix text builder did not respect wide/fullwidth charactors for title line.
Diffstat (limited to 'tests/test_build_text.py')
-rw-r--r-- | tests/test_build_text.py | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/tests/test_build_text.py b/tests/test_build_text.py new file mode 100644 index 00000000..d0472b8f --- /dev/null +++ b/tests/test_build_text.py @@ -0,0 +1,44 @@ +# -*- coding: utf-8 -*- +""" + test_build_text + ~~~~~~~~~~~~~~~ + + Test the build process with Text builder with the test root. + + :copyright: Copyright 2007-2013 by the Sphinx team, see AUTHORS. + :license: BSD, see LICENSE for details. +""" + +from textwrap import dedent + +from docutils.utils import column_width + +from util import * + + +def with_text_app(*args, **kw): + default_kw = { + 'buildername': 'text', + 'srcdir': '(empty)', + 'confoverrides': { + 'project': 'text', + 'master_doc': 'contents', + }, + } + default_kw.update(kw) + return with_app(*args, **default_kw) + + +@with_text_app() +def test_multibyte_title_line(app): + title = u'\u65e5\u672c\u8a9e' + underline = u'=' * column_width(title) + content = u'\n'.join((title, underline, u'')) + + (app.srcdir / 'contents.rst').write_text(content, encoding='utf-8') + app.builder.build_all() + result = (app.outdir / 'contents.txt').text(encoding='utf-8') + + expect_underline = underline.replace('=', '*') + result_underline = result.splitlines()[2].strip() + assert expect_underline == result_underline |