sphinx / tests / test_coverage.py

# -*- coding: utf-8 -*-
"""
    test_coverage
    ~~~~~~~~~~~~~

    Test the coverage builder.

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

import pickle

from util import *


@with_app(buildername='coverage')
def test_build(app):
    app.builder.build_all()

    py_undoc = (app.outdir / 'python.txt').text()
    assert py_undoc.startswith('Undocumented Python objects\n'
                               '===========================\n')
    assert 'test_autodoc\n------------\n' in py_undoc
    assert ' * Class -- missing methods:\n' in py_undoc
    assert ' * process_docstring\n' in py_undoc
    assert ' * function\n' not in py_undoc  # these two are documented
    assert ' * Class\n' not in py_undoc     # in autodoc.txt

    c_undoc = (app.outdir / 'c.txt').text()
    assert c_undoc.startswith('Undocumented C API elements\n'
                              '===========================\n')
    assert 'api.h' in c_undoc
    assert ' * Py_SphinxTest' in c_undoc

    undoc_py, undoc_c = pickle.loads((app.outdir / 'undoc.pickle').text())
    assert len(undoc_c) == 1
    # the key is the full path to the header file, which isn't testable
    assert undoc_c.values()[0] == [('cfunction', 'Py_SphinxTest')]

    assert 'test_autodoc' in undoc_py
    assert 'funcs' in undoc_py['test_autodoc']
    assert 'process_docstring' in undoc_py['test_autodoc']['funcs']
    assert 'classes' in undoc_py['test_autodoc']
    assert 'Class' in undoc_py['test_autodoc']['classes']
    assert 'undocmeth' in undoc_py['test_autodoc']['classes']['Class']
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.