-
-
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: Add validation for custom interpreter option #6354
Conversation
spyder/utils/ipython/kernelspec.py
Outdated
@@ -43,6 +44,9 @@ def argv(self): | |||
# to the kernel sys.path | |||
os.environ.pop('VIRTUAL_ENV', None) | |||
pyexec = CONF.get('main_interpreter', 'executable') | |||
if not is_python_interpreter(pyexec): | |||
pyexec = get_python_executable() | |||
CONF.reset_to_defaults(section='main_interpreter') |
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.
We don't need to reset the entire section. What we need to do is
- Set
'main_interpreter', 'executable'
to be empty. - Make
'main_interpreter', 'default'
True - Make
'main_interpreter', 'custom'
False.
|
||
# Temporary directory | ||
TEMPLOCATION = tempfile.gettempdir() | ||
INTERPRETER = osp.join(TEMPLOCATION, "interpreter") |
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.
You can use the tmpdir
fixture instead of this, like I did here:
https://github.com/spyder-ide/spyder/blob/master/spyder/app/tests/test_mainwindow.py#L216
09674dd
to
eea9347
Compare
eea9347
to
52df8d8
Compare
def test_python_interpreter(tmpdir): | ||
"""Test the validation of the python interpreter.""" | ||
# Set a non existing python interpreter | ||
interpreter = tmpdir.mkdir('interpreter') |
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.
Let's change this to interpreter = tmpdir.mkdir('interpreter').join("python")
to have a more realistic 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.
Also, you need to enclose the statement to the left in a str
call to produce a string. So this really needs to be
interpreter = str(tmpdir.mkdir('interpreter').join('python'))
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.
Thanks @dalthviz, looks good now 👍
Fixes #4958