|
5 | 5 |
|
6 | 6 | import debug_toolbar.utils
|
7 | 7 | from debug_toolbar.utils import (
|
| 8 | + get_editor_url, |
8 | 9 | get_name_from_obj,
|
9 | 10 | get_stack,
|
10 | 11 | get_stack_trace,
|
@@ -171,3 +172,33 @@ def test_non_dict_input(self):
|
171 | 172 | test_input = ["not", "a", "dict"]
|
172 | 173 | result = sanitize_and_sort_request_vars(test_input)
|
173 | 174 | self.assertEqual(result["raw"], test_input)
|
| 175 | + |
| 176 | + |
| 177 | +class GetEditorUrlTestCase(unittest.TestCase): |
| 178 | + @override_settings(DEBUG_TOOLBAR_CONFIG={"EDITOR": "vscode"}) |
| 179 | + def test_get_editor_url(self): |
| 180 | + editors = { |
| 181 | + "cursor": "cursor://file/test.py:5", |
| 182 | + "emacs": "emacs://open?url=file://test.py&line=5", |
| 183 | + "espresso": "x-espresso://open?filepath=test.py&lines=5", |
| 184 | + "idea": "idea://open?file=test.py&line=5", |
| 185 | + "idea-remote": "javascript:(()=>{let r=new XMLHttpRequest; r.open('get','http://localhost:63342/api/file/?file=test.py&line=5');r.send();})()", |
| 186 | + "macvim": "mvim://open/?url=file://test.py&line=5", |
| 187 | + "nova": "nova://open?path=test.py&line=5", |
| 188 | + "pycharm": "pycharm://open?file=test.py&line=5", |
| 189 | + "pycharm-remote": "javascript:(()=>{let r=new XMLHttpRequest; r.open('get','http://localhost:63342/api/file/test.py:5');r.send();})()", |
| 190 | + "sublime": "subl://open?url=file://test.py&line=5", |
| 191 | + "vscode": "vscode://file/test.py:5", |
| 192 | + "vscode-insiders": "vscode-insiders://file/test.py:5", |
| 193 | + "vscode-remote": "vscode://vscode-remote/test.py:5", |
| 194 | + "vscode-insiders-remote": "vscode-insiders://vscode-remote/test.py:5", |
| 195 | + "vscodium": "vscodium://file/test.py:5", |
| 196 | + "windsurf": "windsurf://file/test.py:5", |
| 197 | + } |
| 198 | + for editor, expected_url in editors.items(): |
| 199 | + with ( |
| 200 | + self.subTest(editor=editor), |
| 201 | + override_settings(DEBUG_TOOLBAR_CONFIG={"EDITOR": editor}), |
| 202 | + ): |
| 203 | + url = get_editor_url("test.py", 5) |
| 204 | + self.assertEqual(url, expected_url) |
0 commit comments