sphinx/tests/test_build_changes.py
Martin Packman 71dec3b38e Fix UnboundLocalError when building changes
Split testing of changes builder to its own test file and root.
Improve coverage a little, and add case that fails if a module
directive is included in the rst source.

Correctly handle changesets with a module declared.

Fixes https://github.com/sphinx-doc/sphinx/issues/6134
2019-03-08 13:30:27 +00:00

44 lines
1.3 KiB
Python

# -*- coding: utf-8 -*-
"""
test_build_changes
~~~~~~~~~~~~~~~~~~
Test the ChangesBuilder class.
:copyright: Copyright 2007-2019 by the Sphinx team, see AUTHORS.
:license: BSD, see LICENSE for details.
"""
import pytest
@pytest.mark.sphinx('changes', testroot='changes')
def test_build(app):
app.build()
# TODO: Use better checking of html content
htmltext = (app.outdir / 'changes.html').text()
assert 'New in version 0.6: Some funny stuff.' in htmltext
assert 'Changed in version 0.6: Even more funny stuff.' in htmltext
assert 'Deprecated since version 0.6: Boring stuff.' in htmltext
path_html = (
'<b>Path</b>: <i>deprecated:</i> Deprecated since version 0.6:'
' So, that was a bad idea it turns out.')
assert path_html in htmltext
malloc_html = (
'<b>Test_Malloc</b>: <i>changed:</i> Changed in version 0.6:'
' Can now be replaced with a different allocator.</a>')
assert malloc_html in htmltext
@pytest.mark.sphinx(
'changes', testroot='changes', srcdir='changes-none',
confoverrides={'version': '0.7', 'release': '0.7b1'})
def test_no_changes(app, status):
app.build()
assert 'no changes in version 0.7.' in status.getvalue()
assert not (app.outdir / 'changes.html').exists()