File: test_regex_patterns.py

package info (click to toggle)
fortran-language-server 3.2.2%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 2,268 kB
  • sloc: python: 9,688; f90: 1,195; fortran: 30; makefile: 28; ansic: 20
file content (45 lines) | stat: -rw-r--r-- 1,222 bytes parent folder | download
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

import pytest

from fortls.regex_patterns import create_src_file_exts_regex


@pytest.mark.parametrize(
    "input_exts, input_files, matches",
    [
        (
            [],
            [
                "test.f",
                "test.F",
                "test.f90",
                "test.F90",
                "test.f03",
                "test.F03",
                "test.f18",
                "test.F18",
                "test.f77",
                "test.F77",
                "test.f95",
                "test.F95",
                "test.for",
                "test.FOR",
                "test.fpp",
                "test.FPP",
            ],
            [True] * 16,
        ),
        ([], ["test.ff", "test.f901", "test.f90.ff"], [False, False, False]),
        ([r"\.inc"], ["test.inc", "testinc", "test.inc2"], [True, False, False]),
        (["inc.*"], ["test.inc", "testinc", "test.inc2"], [True, True, True]),
    ],
)
def test_src_file_exts(
    input_exts: list[str],
    input_files: list[str],
    matches: list[bool],
):
    regex = create_src_file_exts_regex(input_exts)
    results = [bool(regex.search(file)) for file in input_files]
    assert results == matches