summaryrefslogtreecommitdiff
path: root/tests/config/loader/test_section.py
blob: b12badee95814fdc45c4c3798f5b1d0b4d3e4448 (plain)
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
from __future__ import annotations

from typing import Any

import pytest

from tox.config.loader.section import Section


@pytest.mark.parametrize(
    ("section", "outcome"),
    [
        (Section("a", "b"), "a:b"),
        (Section(None, "a"), "a"),
    ],
)
def test_section_str(section: Section, outcome: str) -> None:
    assert str(section) == outcome


@pytest.mark.parametrize(
    ("section", "outcome"),
    [
        (Section("a", "b"), "Section(prefix='a', name='b')"),
        (Section(None, "a"), "Section(prefix=None, name='a')"),
    ],
)
def test_section_repr(section: Section, outcome: str) -> None:
    assert repr(section) == outcome


def test_section_eq() -> None:
    assert Section(None, "a") == Section(None, "a")


@pytest.mark.parametrize(
    ("section", "other"),
    [
        (Section("a", "b"), "a-b"),
        (Section(None, "a"), Section("b", "a")),
        (Section("a", "b"), Section("a", "c")),
    ],
)
def test_section_not_eq(section: Section, other: Any) -> None:
    assert section != other