Skip to content

Commit

Permalink
ruff_python_formatter: add CRLF test
Browse files Browse the repository at this point in the history
This test ensures that CRLF line endings are set correctly within a
reformatted code snippet.
  • Loading branch information
BurntSushi committed Nov 22, 2023
1 parent 06c3c22 commit 9d466b9
Show file tree
Hide file tree
Showing 4 changed files with 64 additions and 0 deletions.
3 changes: 3 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,8 @@
crates/ruff_linter/resources/test/fixtures/isort/line_ending_crlf.py text eol=crlf
crates/ruff_linter/resources/test/fixtures/pycodestyle/W605_1.py text eol=crlf

crates/ruff_python_formatter/resources/test/fixtures/ruff/docstring_code_examples_crlf.py text eol=crlf
crates/ruff_python_formatter/tests/snapshots/format@docstring_code_examples_crlf.py.snap text eol=crlf

ruff.schema.json linguist-generated=true text=auto eol=lf
*.md.snap linguist-language=Markdown
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
[
{
"docstring_code": "enabled",
"indent_style": "space",
"indent_width": 4,
"line_ending": "CarriageReturnLineFeed"
}
]
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
def doctest_line_ending():
"""
Do cool stuff.
>>> def foo( x ):
... print( x )
...
... print( x )
"""
pass
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
---
source: crates/ruff_python_formatter/tests/fixtures.rs
input_file: crates/ruff_python_formatter/resources/test/fixtures/ruff/docstring_code_examples_crlf.py
---
## Input
```python
def doctest_line_ending():
"""
Do cool stuff.
>>> def foo( x ):
... print( x )
...
... print( x )
"""
pass
```

## Outputs
### Output 1
```
indent-style = space
line-width = 88
indent-width = 4
quote-style = Double
line-ending = CarriageReturnLineFeed
magic-trailing-comma = Respect
docstring-code = Enabled
preview = Disabled
```

```python
def doctest_line_ending():
"""
Do cool stuff.
>>> def foo(x):
... print(x)
...
... print(x)
"""
pass
```



0 comments on commit 9d466b9

Please sign in to comment.