| 1 |
"""Test the ChangesBuilder class.""" |
| 2 |
|
| 3 |
from __future__ import annotations |
| 4 |
|
| 5 |
from typing import TYPE_CHECKING |
| 6 |
|
| 7 |
import pytest |
| 8 |
|
| 9 |
if TYPE_CHECKING: |
| 10 |
from sphinx.testing.util import SphinxTestApp |
| 11 |
|
| 12 |
|
| 13 |
@pytest.mark.sphinx('changes', testroot='changes') |
| 14 |
def test_build(app: SphinxTestApp) -> None: |
| 15 |
app.build() |
| 16 |
|
| 17 |
# TODO: Use better checking of html content |
| 18 |
htmltext = (app.outdir / 'changes.html').read_text(encoding='utf8') |
| 19 |
assert 'Added in version 0.6: Some funny stuff.' in htmltext |
| 20 |
assert 'Changed in version 0.6: Even more funny stuff.' in htmltext |
| 21 |
assert 'Deprecated since version 0.6: Boring stuff.' in htmltext |
| 22 |
|
| 23 |
path_html = ( |
| 24 |
'<b>Path</b>: <i>deprecated:</i> Deprecated since version 0.6:' |
| 25 |
' So, that was a bad idea it turns out.' |
| 26 |
) |
| 27 |
assert path_html in htmltext |
| 28 |
|
| 29 |
malloc_html = ( |
| 30 |
'<b>void *Test_Malloc(size_t n)</b>: <i>changed:</i> Changed in version 0.6:' |
| 31 |
' Can now be replaced with a different allocator.</a>' |
| 32 |
) |
| 33 |
assert malloc_html in htmltext |
| 34 |
|
| 35 |
|
| 36 |
@pytest.mark.sphinx( |
| 37 |
'changes', |
| 38 |
testroot='changes', |
| 39 |
srcdir='changes-none', |
| 40 |
confoverrides={'version': '0.7', 'release': '0.7b1'}, |
| 41 |
) |
| 42 |
def test_no_changes(app: SphinxTestApp) -> None: |
| 43 |
app.build() |
| 44 |
|
| 45 |
assert 'no changes in version 0.7.' in app.status.getvalue() |
| 46 |
assert not (app.outdir / 'changes.html').exists() |