File: test_title_from_content.py

package info (click to toggle)
sphinx-needs 5.1.0%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 11,924 kB
  • sloc: python: 21,132; javascript: 187; makefile: 89; sh: 29; xml: 10
file content (56 lines) | stat: -rw-r--r-- 1,714 bytes parent folder | download
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
47
48
49
50
51
52
53
54
55
56
from pathlib import Path

import pytest

from tests.util import extract_needs_from_html


@pytest.mark.parametrize(
    "test_app",
    [{"buildername": "html", "srcdir": "doc_test/title_from_content"}],
    indirect=True,
)
def test_title_from_content_scenarios(test_app):
    app = test_app
    app.build()

    html = Path(app.outdir, "index.html").read_text()
    needs = extract_needs_from_html(html)

    assert needs[0].id == "R_12345"
    assert needs[0].title == "Scenario 1 Title"

    assert needs[1].id is not None
    assert needs[1].title == "Scenario 2 Title"

    assert needs[2].id == "R_12346"
    assert needs[2].title == "Scenario 3 Title"

    assert needs[3].id is not None
    assert needs[3].title == "Scenario 4 Title"

    assert needs[4].id == "R_12347"
    assert needs[4].title == "Title is first sentence"

    assert needs[5].id is not None
    assert needs[5].title == "Title should be first sentence"

    # The handling of the ellipses' character varies between Sphinx versions
    # So we're ignoring it in our comparisons.
    assert needs[6].id is not None
    assert needs[6].title == "First sentence will be title, but elided since ..."

    assert needs[7].id == "R_12348"
    assert needs[7].title == "First sentence will be title, but elided since ..."

    assert needs[8].id == "R_12349"
    assert needs[8].title == "Title matches this"

    assert needs[9].id is not None
    assert needs[9].title == "Title should match this"

    assert needs[10].id == "R_12350"
    assert needs[10].title == "First sentence is really long so this should be..."

    assert needs[11].id is not None
    assert needs[11].title == "First sentence is really long so this should be..."