File: conftest.py

package info (click to toggle)
pygments 2.19.2%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 10,668 kB
  • sloc: python: 105,287; javascript: 238; makefile: 142; sh: 84; lisp: 74
file content (31 lines) | stat: -rw-r--r-- 912 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
"""
    Generated lexer tests
    ~~~~~~~~~~~~~~~~~~~~~

    Checks that lexers output the expected tokens for each sample
    under lexers/*/test_*.txt.

    After making a change, rather than updating the samples manually,
    run `pytest --update-goldens tests/lexers`.

    To add a new sample, create a new file matching this pattern.
    The directory must match the alias of the lexer to be used.
    Populate only the input, then just `--update-goldens`.

    :copyright: Copyright 2006-2025 by the Pygments team, see AUTHORS.
    :license: BSD, see LICENSE for details.
"""

import pytest

from tests.conftest import LexerInlineTestItem


def pytest_collect_file(parent, file_path):
    if file_path.suffix == '.txt':
        return LexerTestFile.from_parent(parent, path=file_path)


class LexerTestFile(pytest.File):
    def collect(self):
        yield LexerInlineTestItem.from_parent(self, name='')