Skip to content

Commit 72bf7ab

Browse files
committed
fake a ruff executable for testing the executable parameter
1 parent c235923 commit 72bf7ab

File tree

1 file changed

+14
-8
lines changed

1 file changed

+14
-8
lines changed

tests/test_ruff_lint.py

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
# Copyright 2017-2020 Palantir Technologies, Inc.
22
# Copyright 2021- Python Language Server Contributors.
33

4+
import chmod
45
import os
56
import sys
67
import tempfile
@@ -100,17 +101,22 @@ def test_ruff_config_param(workspace):
100101

101102
def test_ruff_executable_param(workspace):
102103
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()]
105107

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)
108112

109-
_name, doc = temp_document(DOC, workspace)
110-
ruff_lint.pylsp_lint(workspace, doc)
113+
workspace._config.update({"plugins": {"ruff": {"executable": ruff_executable}}})
111114

112-
(call_args,) = popen_mock.call_args[0]
113-
assert ruff_executable in call_args
115+
_name, doc = temp_document(DOC, workspace)
116+
ruff_lint.pylsp_lint(workspace, doc)
117+
118+
(call_args,) = popen_mock.call_args[0]
119+
assert ruff_executable in call_args
114120

115121

116122
def get_ruff_settings(workspace, doc, config_str):

0 commit comments

Comments
 (0)