File: test_cython_templating.py

package info (click to toggle)
scikit-learn 1.4.2%2Bdfsg-8
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 25,036 kB
  • sloc: python: 201,105; cpp: 5,790; ansic: 854; makefile: 304; sh: 56; javascript: 20
file content (22 lines) | stat: -rw-r--r-- 834 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
import pathlib

import pytest

import sklearn


def test_files_generated_by_templates_are_git_ignored():
    """Check the consistence of the files generated from template files."""
    gitignore_file = pathlib.Path(sklearn.__file__).parent.parent / ".gitignore"
    if not gitignore_file.exists():
        pytest.skip("Tests are not run from the source folder")

    base_dir = pathlib.Path(sklearn.__file__).parent
    ignored_files = gitignore_file.read_text().split("\n")
    ignored_files = [pathlib.Path(line) for line in ignored_files]

    for filename in base_dir.glob("**/*.tp"):
        filename = filename.relative_to(base_dir.parent)
        # From "path/to/template.p??.tp" to "path/to/template.p??"
        filename_wo_tempita_suffix = filename.with_suffix("")
        assert filename_wo_tempita_suffix in ignored_files