summaryrefslogtreecommitdiff
path: root/tests/examplefiles/conftest.py
blob: a1aa0ef7017a9d96f5d429387124da051aa08a42 (plain)
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
"""
    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/examplefiles`.

    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 2021 by the Pygments team, see AUTHORS.
    :license: BSD, see LICENSE for details.
"""

import pathlib
import pytest

from tests.conftest import LexerSeparateTestItem


def pytest_collect_file(parent, path):
    if path.ext != '.output' and path.basename != 'conftest.py':
        return LexerTestFile.from_parent(parent, path=pathlib.Path(path))


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