File: test_build_changes.py

package info (click to toggle)
sphinx 9.1.0-1
  • links: PTS, VCS
  • area: main
  • in suites: experimental
  • size: 28,732 kB
  • sloc: python: 109,394; javascript: 37,318; perl: 449; makefile: 183; sh: 37; xml: 19; ansic: 2
file content (46 lines) | stat: -rw-r--r-- 1,355 bytes parent folder | download | duplicates (10)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
"""Test the ChangesBuilder class."""

from __future__ import annotations

from typing import TYPE_CHECKING

import pytest

if TYPE_CHECKING:
    from sphinx.testing.util import SphinxTestApp


@pytest.mark.sphinx('changes', testroot='changes')
def test_build(app: SphinxTestApp) -> None:
    app.build()

    # TODO: Use better checking of html content
    htmltext = (app.outdir / 'changes.html').read_text(encoding='utf8')
    assert 'Added 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>void *Test_Malloc(size_t n)</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: SphinxTestApp) -> None:
    app.build()

    assert 'no changes in version 0.7.' in app.status.getvalue()
    assert not (app.outdir / 'changes.html').exists()