-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
PR: Fix a bug when running a file with a single quote character in its name #6772
PR: Fix a bug when running a file with a single quote character in its name #6772
Conversation
The test that covers this ( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A few minor notes.
spyder/app/tests/test_mainwindow.py
Outdated
@@ -763,19 +773,20 @@ def test_set_new_breakpoints(main_window, qtbot): | |||
main_window.editor.clear_all_breakpoints() | |||
main_window.editor.close_file() | |||
|
|||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why was this line removed? Two spaces between top-level functions, I thought...accident?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yep, ty
spyder/app/tests/test_mainwindow.py
Outdated
@@ -1465,4 +1476,4 @@ def test_render_issue(): | |||
|
|||
|
|||
if __name__ == "__main__": | |||
pytest.main() | |||
pytest.main(['-x', os.path.basename(__file__), '-v', '-rw']) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there is a reason this was changed, particularly adding the -x
option? In general, when running locally I usually use -v
(or -vv
) and always use -rw
, but almost never want -x
and would have to routinely modify the runtests.py
file to change this if I wanted to run the whole test suite with this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Running the whole suite when trying to make a single test work is not very efficient. I forgot to exclude this change when committing, I'll simply revert in another commit.
spyder/plugins/editor.py
Outdated
dirname = osp.dirname(fname) | ||
|
||
# Escape single and double quotes in fname and dirname | ||
# (Fixes Issue 2158) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add # sign for consistency with previous comment ( #2158 )
spyder/app/tests/test_mainwindow.py
Outdated
@@ -135,6 +135,16 @@ def find_desired_tab_in_window(tab_name, window): | |||
return None, None | |||
|
|||
|
|||
def setup_file_test(): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please use the tmpdir
fixture for the location of this file.
spyder/app/tests/test_mainwindow.py
Outdated
@@ -770,12 +780,14 @@ def test_set_new_breakpoints(main_window, qtbot): | |||
def test_run_code(main_window, qtbot): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please remove the skipif
condition for Windows here.
Hello @jnsebgosselin! Thanks for updating the PR.
|
The failure in CircleCI is unrelated to this. |
Thanks @ccordoba12 ! |
Fixes #6771
Blocking PR #6750
Related to Issue #2158
In spyder/plugins/editor.py, single and double quotes are escaped before running a file from the editor :
https://github.com/spyder-ide/spyder/blob/v3.2.8/spyder/plugins/editor.py#L2380
In Windows, this causes
osp.dirname(fname)
to return the wrong path if there is a'
or"
character in the name of the file. For example :returns in Windows
'C:\test'
instead of'C:
. Therefore, to fix this issue, fname's dirname must be saved in a temporary variable before the single or double quote are escaped.Note:
In Windows, the following characters are not allowed for folder or file names :