~ubuntuone-pqm-team/sphinx/stable

« back to all changes in this revision

Viewing changes to tests/test_ext_coverage.py

  • Committer: Ricardo Kirkner
  • Date: 2015-04-15 19:42:56 UTC
  • Revision ID: ricardo.kirkner@canonical.com-20150415194256-r6wb9fxewu7g3yne
Tags: 1.3.1
imported Sphinx 1.3.1 from tarball

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
# -*- coding: utf-8 -*-
 
2
"""
 
3
    test_coverage
 
4
    ~~~~~~~~~~~~~
 
5
 
 
6
    Test the coverage builder.
 
7
 
 
8
    :copyright: Copyright 2007-2015 by the Sphinx team, see AUTHORS.
 
9
    :license: BSD, see LICENSE for details.
 
10
"""
 
11
 
 
12
import pickle
 
13
 
 
14
from util import with_app
 
15
 
 
16
 
 
17
@with_app(buildername='coverage')
 
18
def test_build(app, status, warning):
 
19
    app.builder.build_all()
 
20
 
 
21
    py_undoc = (app.outdir / 'python.txt').text()
 
22
    assert py_undoc.startswith('Undocumented Python objects\n'
 
23
                               '===========================\n')
 
24
    assert 'test_autodoc\n------------\n' in py_undoc
 
25
    assert ' * Class -- missing methods:\n' in py_undoc
 
26
    assert ' * process_docstring\n' in py_undoc
 
27
    assert ' * function\n' not in py_undoc  # these two are documented
 
28
    assert ' * Class\n' not in py_undoc     # in autodoc.txt
 
29
 
 
30
    assert ' * mod -- No module named mod'  # in the "failed import" section
 
31
 
 
32
    c_undoc = (app.outdir / 'c.txt').text()
 
33
    assert c_undoc.startswith('Undocumented C API elements\n'
 
34
                              '===========================\n')
 
35
    assert 'api.h' in c_undoc
 
36
    assert ' * Py_SphinxTest' in c_undoc
 
37
 
 
38
    undoc_py, undoc_c = pickle.loads((app.outdir / 'undoc.pickle').bytes())
 
39
    assert len(undoc_c) == 1
 
40
    # the key is the full path to the header file, which isn't testable
 
41
    assert list(undoc_c.values())[0] == set([('function', 'Py_SphinxTest')])
 
42
 
 
43
    assert 'test_autodoc' in undoc_py
 
44
    assert 'funcs' in undoc_py['test_autodoc']
 
45
    assert 'process_docstring' in undoc_py['test_autodoc']['funcs']
 
46
    assert 'classes' in undoc_py['test_autodoc']
 
47
    assert 'Class' in undoc_py['test_autodoc']['classes']
 
48
    assert 'undocmeth' in undoc_py['test_autodoc']['classes']['Class']