File: test_classifiers.py

package info (click to toggle)
trove-classifiers 2026.1.14.14-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 204 kB
  • sloc: python: 1,096; makefile: 25
file content (81 lines) | stat: -rw-r--r-- 2,332 bytes parent folder | download | duplicates (3)
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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
import pytest

from tests.lib import trove_tester, InvalidClassifier


@pytest.mark.parametrize(
    "classifiers, deprecated_classifiers",
    [
        (
            {
                "Foo :: Bar",
                "Foo :: Bar :: Baz",
            },
            {},
        ),
        ({"Foo :: Bar"}, {"Biz :: Baz": ["Foo :: Bar"]}),
    ],
)
def test_success(classifiers, deprecated_classifiers):
    trove_tester(classifiers, deprecated_classifiers)


@pytest.mark.parametrize(
    "classifiers, deprecated_classifiers, expected",
    [
        (
            {"Foo", "Foo :: Bar"},
            {},
            "Top-level classifier 'Foo' is invalid",
        ),
        ({"Foo :: Bar :: Baz"}, {}, "Classifier 'Foo :: Bar' is missing"),
        (
            {
                "Foo :: Bar",
            },
            {"Biz :: Baz": ["Bing :: Bang"]},
            "Classifier 'Bing :: Bang' does not exist",
        ),
        (
            {
                "Foo :: Bar",
            },
            {"Foo :: Bar": []},
            "Classifier 'Foo :: Bar' in both valid and deprecated classifiers",
        ),
        ({"Private :: Foo"}, {}, "Classifiers starting with 'Private' are invalid"),
        ({"private :: Foo"}, {}, "Classifiers starting with 'Private' are invalid"),
        ({"Foo :: Private"}, {}, "Classifiers starting with 'Private' are invalid"),
        ({"Foo :: private"}, {}, "Classifiers starting with 'Private' are invalid"),
        (
            {" Foo :: Bar"},
            {},
            "Classifiers starting or ending with whitespace are invalid",
        ),
        (
            {"Foo :: Bar "},
            {},
            "Classifiers starting or ending with whitespace are invalid",
        ),
        (
            {"Foo: :: Bar"},
            {},
            "Classifiers containing ':' are invalid",
        ),
        (
            {"Foo :: B:ar"},
            {},
            "Classifiers containing ':' are invalid",
        ),
        (
            {"Foo :: Bar: Baz"},
            {},
            "Classifiers containing ':' are invalid",
        ),
    ],
)
def test_failure(classifiers, deprecated_classifiers, expected):
    with pytest.raises(InvalidClassifier) as excinfo:
        trove_tester(classifiers, deprecated_classifiers)

    assert excinfo.value.args == (expected,)