chore: import upstream snapshot with attribution
This commit is contained in:
@@ -0,0 +1,46 @@
|
||||
from pathlib import Path
|
||||
|
||||
import pytest
|
||||
from clint.config import Config
|
||||
from clint.index import SymbolIndex
|
||||
from clint.linter import Position, Range, lint_file
|
||||
from clint.rules.example_syntax_error import ExampleSyntaxError
|
||||
|
||||
|
||||
def test_example_syntax_error(index: SymbolIndex) -> None:
|
||||
code = '''
|
||||
def bad():
|
||||
"""
|
||||
.. code-block:: python
|
||||
|
||||
def f():
|
||||
|
||||
"""
|
||||
|
||||
def good():
|
||||
"""
|
||||
.. code-block:: python
|
||||
|
||||
def f():
|
||||
return "This is a good example"
|
||||
"""
|
||||
'''
|
||||
config = Config(select={ExampleSyntaxError.name})
|
||||
violations = lint_file(Path("test.py"), code, config, index)
|
||||
assert len(violations) == 1
|
||||
assert all(isinstance(v.rule, ExampleSyntaxError) for v in violations)
|
||||
assert violations[0].range == Range(Position(5, 8))
|
||||
|
||||
|
||||
@pytest.mark.parametrize("suffix", [".md", ".mdx"])
|
||||
def test_example_syntax_error_markdown(index: SymbolIndex, suffix: str) -> None:
|
||||
code = """
|
||||
```python
|
||||
def g():
|
||||
```
|
||||
"""
|
||||
config = Config(select={ExampleSyntaxError.name})
|
||||
violations = lint_file(Path("test").with_suffix(suffix), code, config, index)
|
||||
assert len(violations) == 1
|
||||
assert all(isinstance(v.rule, ExampleSyntaxError) for v in violations)
|
||||
assert violations[0].range == Range(Position(2, 0))
|
||||
Reference in New Issue
Block a user