Files
kiauh/tests/line_matching/match_section/test_match_section.py
dw-0 2f924a2550 Squashed 'kiauh/core/submodules/simple_config_parser/' content from commit 90081a6
git-subtree-dir: kiauh/core/submodules/simple_config_parser
git-subtree-split: 90081a6539ec38adf6a1a5bb707a0e9934567c7f
2024-09-24 19:22:13 +02:00

40 lines
1.6 KiB
Python

# ======================================================================= #
# Copyright (C) 2024 Dominik Willner <th33xitus@gmail.com> #
# #
# https://github.com/dw-0/simple-config-parser #
# #
# This file may be distributed under the terms of the GNU GPLv3 license #
# ======================================================================= #
from pathlib import Path
import pytest
from src.simple_config_parser.simple_config_parser import SimpleConfigParser
from tests.utils import load_testdata_from_file
BASE_DIR = Path(__file__).parent.joinpath("test_data")
MATCHING_TEST_DATA_PATH = BASE_DIR.joinpath("matching_data.txt")
NON_MATCHING_TEST_DATA_PATH = BASE_DIR.joinpath("non_matching_data.txt")
@pytest.fixture
def parser():
return SimpleConfigParser()
@pytest.mark.parametrize("line", load_testdata_from_file(MATCHING_TEST_DATA_PATH))
def test_match_section(parser, line):
"""Test that a line matches the definition of a section"""
assert (
parser._match_section(line) is True
), f"Expected line '{line}' to match section definition!"
@pytest.mark.parametrize("line", load_testdata_from_file(NON_MATCHING_TEST_DATA_PATH))
def test_non_matching_section(parser, line):
"""Test that a line does not match the definition of a section"""
assert (
parser._match_section(line) is False
), f"Expected line '{line}' to not match section definition!"