Skip to content
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

Merged
merged 6 commits into from
Feb 3, 2018

Conversation

dalthviz
Copy link
Member

@dalthviz dalthviz commented Feb 1, 2018

Fixes #4958

@dalthviz dalthviz added this to the v3.2.7 milestone Feb 1, 2018
@dalthviz dalthviz self-assigned this Feb 1, 2018
@dalthviz dalthviz requested a review from ccordoba12 February 1, 2018 01:02
@dalthviz dalthviz changed the title Validation of the custom interpreter preference PR: Validation of the custom interpreter preference Feb 1, 2018
@@ -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')
Copy link
Member

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

  1. Set 'main_interpreter', 'executable' to be empty.
  2. Make 'main_interpreter', 'default' True
  3. Make 'main_interpreter', 'custom' False.


# Temporary directory
TEMPLOCATION = tempfile.gettempdir()
INTERPRETER = osp.join(TEMPLOCATION, "interpreter")
Copy link
Member

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

@dalthviz dalthviz force-pushed the fixes_issue_4958 branch 2 times, most recently from 09674dd to eea9347 Compare February 1, 2018 16:39
def test_python_interpreter(tmpdir):
"""Test the validation of the python interpreter."""
# Set a non existing python interpreter
interpreter = tmpdir.mkdir('interpreter')
Copy link
Member

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.

Copy link
Member

@ccordoba12 ccordoba12 Feb 2, 2018

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

Copy link
Member

@ccordoba12 ccordoba12 left a 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 👍

@ccordoba12 ccordoba12 changed the title PR: Validation of the custom interpreter preference PR: Add validation for custom interpreter option Feb 3, 2018
@ccordoba12 ccordoba12 merged commit 24d8444 into spyder-ide:3.x Feb 3, 2018
ccordoba12 added a commit that referenced this pull request Feb 3, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants