|
2 | 2 | # Copyright 2021- Python Language Server Contributors.
|
3 | 3 |
|
4 | 4 | import os
|
| 5 | +import stat |
5 | 6 | import sys
|
6 | 7 | import tempfile
|
7 | 8 | from unittest.mock import Mock, patch
|
@@ -100,17 +101,24 @@ def test_ruff_config_param(workspace):
|
100 | 101 |
|
101 | 102 | def test_ruff_executable_param(workspace):
|
102 | 103 | with patch("pylsp_ruff.plugin.Popen") as popen_mock:
|
103 |
| - mock_instance = popen_mock.return_value |
104 |
| - mock_instance.communicate.return_value = [bytes(), bytes()] |
| 104 | + with tempfile.NamedTemporaryFile() as ruff_exe: |
| 105 | + mock_instance = popen_mock.return_value |
| 106 | + mock_instance.communicate.return_value = [bytes(), bytes()] |
105 | 107 |
|
106 |
| - ruff_executable = "/tmp/ruff" |
107 |
| - workspace._config.update({"plugins": {"ruff": {"executable": ruff_executable}}}) |
| 108 | + ruff_executable = ruff_exe.name |
| 109 | + # chmod +x the file |
| 110 | + st = os.stat(ruff_executable) |
| 111 | + os.chmod(ruff_executable, st.st_mode | stat.S_IEXEC) |
108 | 112 |
|
109 |
| - _name, doc = temp_document(DOC, workspace) |
110 |
| - ruff_lint.pylsp_lint(workspace, doc) |
| 113 | + workspace._config.update( |
| 114 | + {"plugins": {"ruff": {"executable": ruff_executable}}} |
| 115 | + ) |
111 | 116 |
|
112 |
| - (call_args,) = popen_mock.call_args[0] |
113 |
| - assert ruff_executable in call_args |
| 117 | + _name, doc = temp_document(DOC, workspace) |
| 118 | + ruff_lint.pylsp_lint(workspace, doc) |
| 119 | + |
| 120 | + (call_args,) = popen_mock.call_args[0] |
| 121 | + assert ruff_executable in call_args |
114 | 122 |
|
115 | 123 |
|
116 | 124 | def get_ruff_settings(workspace, doc, config_str):
|
|
0 commit comments