summaryrefslogtreecommitdiffstats
path: root/tests/lint_tests/conftest.py
blob: 2c54eb7afc6b381988cadbce818c305dd66ef83b (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
46
47
48
49
import pytest
from debian.debian_support import DpkgArchTable

from debputy._deb_options_profiles import DebBuildOptionsAndProfiles
from debputy.architecture_support import DpkgArchitectureBuildProcessValuesTable
from debputy.packages import DctrlParser
from debputy.util import setup_logging

try:
    from lsprotocol.types import Diagnostic
    from debputy.lsp.spellchecking import disable_spellchecking

    HAS_LSPROTOCOL = True
except ImportError:
    HAS_LSPROTOCOL = False

    def disable_spellchecking() -> None:
        pass


@pytest.fixture(scope="session", autouse=True)
def enable_logging() -> None:
    if not HAS_LSPROTOCOL:
        pytest.skip("Missing python3-lsprotocol")
    setup_logging(reconfigure_logging=True)


@pytest.fixture(scope="session", autouse=True)
def disable_spellchecking_fixture() -> None:
    # CI/The buildd does not install relevant, so this is mostly about ensuring
    # consistent behavior between clean and "unclean" build/test environments
    disable_spellchecking()


@pytest.fixture
def lint_dctrl_parser(
    dpkg_arch_query: DpkgArchTable,
    amd64_dpkg_architecture_variables: DpkgArchitectureBuildProcessValuesTable,
    no_profiles_or_build_options: DebBuildOptionsAndProfiles,
) -> DctrlParser:
    return DctrlParser(
        frozenset(),
        frozenset(),
        True,
        True,
        amd64_dpkg_architecture_variables,
        dpkg_arch_query,
        no_profiles_or_build_options,
    )