/
githubmirror
/
setools
Обзор
Документация
Войти
/
githubmirror
/
setools
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
main
tests/library/test_boolquery.py
41 строка
1 KB
Chris PeBenito
TestBoolQuery: Update tests to pytest fixtures.
19 апр 2024, 01:54
19 апр 2024, 01:54
f0592c5
Код
Авторство
О чём код?
# Copyright 2014, Tresys Technology, LLC # # SPDX-License-Identifier: GPL-2.0-only # import pytest import setools @pytest.mark.obj_args("tests/library/boolquery.conf") class TestBoolQuery: def test_unset(self, compiled_policy: setools.SELinuxPolicy) -> None: """Boolean query with no criteria.""" # query with no parameters gets all Booleans. allbools = sorted(str(b) for b in compiled_policy.bools()) q = setools.BoolQuery(compiled_policy) qbools = sorted(str(b) for b in q.results()) assert allbools == qbools def test_name_exact(self, compiled_policy: setools.SELinuxPolicy) -> None: """Boolean query with exact match""" q = setools.BoolQuery(compiled_policy, name="test1") bools = sorted(str(b) for b in q.results()) assert ["test1"] == bools def test_name_regex(self, compiled_policy: setools.SELinuxPolicy) -> None: """Boolean query with regex match.""" q = setools.BoolQuery(compiled_policy, name="test2(a|b)", name_regex=True) bools = sorted(str(b) for b in q.results()) assert ["test2a", "test2b"] == bools def test_default(self, compiled_policy: setools.SELinuxPolicy) -> None: """Boolean query with default state match.""" q = setools.BoolQuery(compiled_policy, default=False) bools = sorted(str(b) for b in q.results()) assert ["test10a", "test10b"] == bools