Skip to content

Commit 47e6e76

Browse files
committed
ruff_python_formatter: add CRLF test
This test ensures that CRLF line endings are set correctly within a reformatted code snippet.
1 parent d51ae51 commit 47e6e76

File tree

4 files changed

+64
-0
lines changed

4 files changed

+64
-0
lines changed

.gitattributes

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,8 @@
33
crates/ruff_linter/resources/test/fixtures/isort/line_ending_crlf.py text eol=crlf
44
crates/ruff_linter/resources/test/fixtures/pycodestyle/W605_1.py text eol=crlf
55

6+
crates/ruff_python_formatter/resources/test/fixtures/ruff/docstring_code_examples_crlf.py text eol=crlf
7+
crates/ruff_python_formatter/tests/snapshots/format@docstring_code_examples_crlf.py.snap text eol=crlf
8+
69
ruff.schema.json linguist-generated=true text=auto eol=lf
710
*.md.snap linguist-language=Markdown
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
[
2+
{
3+
"docstring_code": "enabled",
4+
"indent_style": "space",
5+
"indent_width": 4,
6+
"line_ending": "CarriageReturnLineFeed"
7+
}
8+
]
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
def doctest_line_ending():
2+
"""
3+
Do cool stuff.
4+
>>> def foo( x ):
5+
... print( x )
6+
...
7+
... print( x )
8+
"""
9+
pass
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
---
2+
source: crates/ruff_python_formatter/tests/fixtures.rs
3+
input_file: crates/ruff_python_formatter/resources/test/fixtures/ruff/docstring_code_examples_crlf.py
4+
---
5+
## Input
6+
```python
7+
def doctest_line_ending():
8+
"""
9+
Do cool stuff.
10+
>>> def foo( x ):
11+
... print( x )
12+
...
13+
... print( x )
14+
"""
15+
pass
16+
```
17+
18+
## Outputs
19+
### Output 1
20+
```
21+
indent-style = space
22+
line-width = 88
23+
indent-width = 4
24+
quote-style = Double
25+
line-ending = CarriageReturnLineFeed
26+
magic-trailing-comma = Respect
27+
docstring-code = Enabled
28+
preview = Disabled
29+
```
30+
31+
```python
32+
def doctest_line_ending():
33+
"""
34+
Do cool stuff.
35+
>>> def foo(x):
36+
... print(x)
37+
...
38+
... print(x)
39+
"""
40+
pass
41+
```
42+
43+
44+

0 commit comments

Comments
 (0)