File: test_utils.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 (46 lines) | stat: -rw-r--r-- 1,852 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
"""Test utility functions."""

import pytest

from sphinx_needs.api.need import _split_list_with_dyn_funcs


@pytest.mark.parametrize(
    "input, expected",
    [
        (None, []),
        ([], []),
        (["a"], [("a", False)]),
        ("a", [("a", False)]),
        ("a,", [("a", False)]),
        ("[[a]]", [("[[a]]", True)]),
        ("a,b", [("a", False), ("b", False)]),
        ("a, b", [("a", False), ("b", False)]),
        ("a,b,", [("a", False), ("b", False)]),
        ("a|b", [("a", False), ("b", False)]),
        ("a| b", [("a", False), ("b", False)]),
        ("a|b,", [("a", False), ("b", False)]),
        ("a;b", [("a", False), ("b", False)]),
        ("a; b", [("a", False), ("b", False)]),
        ("a;b,", [("a", False), ("b", False)]),
        ("a,b|c;d,", [("a", False), ("b", False), ("c", False), ("d", False)]),
        ("[[x,y]],b", [("[[x,y]]", True), ("b", False)]),
        ("a,[[x,y]],b", [("a", False), ("[[x,y]]", True), ("b", False)]),
        ("a,[[x,y", [("a", False), ("[[x,y]]", True)]),
        ("a,[[x,y]", [("a", False), ("[[x,y]]", True)]),
        # previously in from _split_value in needextend.py
        ("[[a]]b", [("[[a]]b", True)]),
        ("[[a;]],", [("[[a;]]", True)]),
        ("a,b;c", [("a", False), ("b", False), ("c", False)]),
        ("[[a]],[[b]];[[c]]", [("[[a]]", True), ("[[b]]", True), ("[[c]]", True)]),
        (" a ,, b; c ", [("a", False), ("b", False), ("c", False)]),
        (
            " [[a]] ,, [[b]] ; [[c]] ",
            [("[[a]]", True), ("[[b]]", True), ("[[c]]", True)],
        ),
        ("a,[[b]];c", [("a", False), ("[[b]]", True), ("c", False)]),
        (" a ,, [[b;]] ; c ", [("a", False), ("[[b;]]", True), ("c", False)]),
    ],
)
def test_split_list_with_dyn_funcs(input, expected):
    assert list(_split_list_with_dyn_funcs(input, None)) == expected