@@ -39,6 +39,15 @@ def unformatted_pyi_document(workspace):
3939 return Document (uri , workspace )
4040
4141
42+ @pytest .fixture
43+ def unformatted_crlf_document (workspace ):
44+ path = fixtures_dir / "unformatted-crlf.py"
45+ uri = f"file:/{ path } "
46+ with open (path , "r" , newline = "" ) as f :
47+ source = f .read ()
48+ return Document (uri , workspace , source = source )
49+
50+
4251@pytest .fixture
4352def formatted_document (workspace ):
4453 path = fixtures_dir / "formatted.txt"
@@ -53,6 +62,15 @@ def formatted_pyi_document(workspace):
5362 return Document (uri , workspace )
5463
5564
65+ @pytest .fixture
66+ def formatted_crlf_document (workspace ):
67+ path = fixtures_dir / "formatted-crlf.py"
68+ uri = f"file:/{ path } "
69+ with open (path , "r" , newline = "" ) as f :
70+ source = f .read ()
71+ return Document (uri , workspace , source = source )
72+
73+
5674@pytest .fixture
5775def invalid_document (workspace ):
5876 path = fixtures_dir / "invalid.txt"
@@ -225,3 +243,17 @@ def test_entry_point():
225243
226244 module = entry_point .load ()
227245 assert isinstance (module , types .ModuleType )
246+
247+
248+ def test_pylsp_format_crlf_document (unformatted_crlf_document , formatted_crlf_document ):
249+ result = pylsp_format_document (unformatted_crlf_document )
250+
251+ assert result == [
252+ {
253+ "range" : {
254+ "start" : {"line" : 0 , "character" : 0 },
255+ "end" : {"line" : 4 , "character" : 0 },
256+ },
257+ "newText" : formatted_crlf_document .source ,
258+ }
259+ ]
0 commit comments