sphinx / tests / test_build_texinfo.py

# -*- coding: utf-8 -*-

    Test the build process with Texinfo builder with the test root.

    :copyright: Copyright 2007-2011 by the Sphinx team, see AUTHORS.
    :license: BSD, see LICENSE for details.

import os
import re
import sys
from StringIO import StringIO
from subprocess import Popen, PIPE

from sphinx.writers.texinfo import TexinfoTranslator

from util import *
from test_build_html import ENV_WARNINGS

def teardown_module():
    (test_root / '_build').rmtree(True)

texinfo_warnfile = StringIO()

None:None: WARNING: no matching candidate for image URI u'foo.\\*'
None:None: WARNING: no matching candidate for image URI u'svgimg.\\*'

if sys.version_info >= (3, 0):
    TEXINFO_WARNINGS = remove_unicode_literals(TEXINFO_WARNINGS)

@with_app(buildername='texinfo', warning=texinfo_warnfile, cleanenv=True)
def test_texinfo(app):
    TexinfoTranslator.ignore_missing_images = True
    texinfo_warnings = texinfo_warnfile.getvalue().replace(os.sep, '/')
    texinfo_warnings_exp = TEXINFO_WARNINGS % {
            'root': re.escape(app.srcdir.replace(os.sep, '/'))}
    assert re.match(texinfo_warnings_exp + '$', texinfo_warnings), \
           'Warnings don\'t match:\n' + \
           '--- Expected (regex):\n' + texinfo_warnings_exp + \
           '--- Got:\n' + texinfo_warnings
    # now, try to run makeinfo over it
    cwd = os.getcwd()
            p = Popen(['makeinfo', '--no-split', 'SphinxTests.texi'],
                      stdout=PIPE, stderr=PIPE)
        except OSError:
            pass  # most likely makeinfo was not found
            stdout, stderr = p.communicate()
            retcode = p.returncode
            if retcode != 0:
                print stdout
                print stderr
                del app.cleanup_trees[:]
                assert False, 'makeinfo exited with return code %s' % retcode
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.