| 1 |
""" |
| 2 |
Generated lexer tests |
| 3 |
~~~~~~~~~~~~~~~~~~~~~ |
| 4 |
|
| 5 |
Checks that lexers output the expected tokens for each sample |
| 6 |
under lexers/*/test_*.txt. |
| 7 |
|
| 8 |
After making a change, rather than updating the samples manually, |
| 9 |
run `pytest --update-goldens tests/lexers`. |
| 10 |
|
| 11 |
To add a new sample, create a new file matching this pattern. |
| 12 |
The directory must match the alias of the lexer to be used. |
| 13 |
Populate only the input, then just `--update-goldens`. |
| 14 |
|
| 15 |
:copyright: Copyright 2006-present by the Pygments team, see AUTHORS. |
| 16 |
:license: BSD, see LICENSE for details. |
| 17 |
""" |
| 18 |
|
| 19 |
import pytest |
| 20 |
|
| 21 |
from tests.conftest import LexerInlineTestItem |
| 22 |
|
| 23 |
|
| 24 |
def pytest_collect_file(parent, file_path): |
| 25 |
if file_path.suffix == '.txt': |
| 26 |
return LexerTestFile.from_parent(parent, path=file_path) |
| 27 |
|
| 28 |
|
| 29 |
class LexerTestFile(pytest.File): |
| 30 |
def collect(self): |
| 31 |
yield LexerInlineTestItem.from_parent(self, name='') |