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 test with non-ascii directory for consoles stderr file #5013

Merged
merged 7 commits into from
Aug 28, 2017

Conversation

dalthviz
Copy link
Member

Fixes #4836

@dalthviz dalthviz added this to the v3.2.2 milestone Aug 20, 2017
@dalthviz dalthviz self-assigned this Aug 20, 2017
@dalthviz dalthviz requested a review from ccordoba12 August 20, 2017 04:01
@dalthviz dalthviz changed the base branch from master to 3.x August 20, 2017 04:02
@dalthviz
Copy link
Member Author

@ccordoba12 should I do something else with this one?

if not osp.isdir(programs.TEMPDIR):
os.mkdir(programs.TEMPDIR)
if not osp.isdir(osp.join(programs.TEMPDIR, u'測試', u'اختبار')):
os.makedirs(osp.join(programs.TEMPDIR, u'測試', u'اختبار'))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@dalthviz, I don't like this test directory to be part of our sourcecode.

Please add a new parameter to __init__ called test_dir=TEMPDIR. With that this should look like:

if self.testing:
    if not osp.isdir(test_dir):
        os.makedirs(test_dir)

Then in our tests you can change that parameter by this directory containing Chinese and Arabic characters.

if not self.testing:
stderr_file = osp.join(TEMPDIR, stderr_file)
else:
stderr_file = osp.join(TEMPDIR, u'測試', u'اختبار', stderr_file)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please also find a solution similar to the one I posted above to avoid putting this temp directory as part of our source code.

@pep8speaks
Copy link

pep8speaks commented Aug 26, 2017

Hello @dalthviz! Thanks for updating the PR.

Cheers ! There are no PEP8 issues in this Pull Request. 🍻

Comment last updated on August 27, 2017 at 19:07 Hours UTC

@@ -74,9 +74,45 @@ def close_console():
return console


@pytest.fixture
def ipyconsole_stderr(request):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@dalthviz, are you sure we need an extra fixture for this? Is it not possible to add an extra parameter to the previous fixture?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep, you are right 👍 no need of a extra fixture

@@ -590,7 +590,7 @@ class IPythonConsole(SpyderPluginWidget):
focus_changed = Signal()
edit_goto = Signal((str, int, str), (str, int, str, bool))

def __init__(self, parent, testing=False):
def __init__(self, parent, testing=False, test_dir=programs.TEMPDIR):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please use here only TEMPDIR, so import it from programs with

from programs import TEMPDIR

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We also need to add

self.test_dir = test_dir

@@ -932,7 +933,8 @@ def write_to_stdin(self, line):
@Slot(bool)
@Slot(str)
@Slot(bool, str)
def create_new_client(self, give_focus=True, filename=''):
def create_new_client(self, give_focus=True, filename='',
stderr_dir=programs.TEMPDIR):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please don't add a new parameter here because we'd need to also add new Slot's

@@ -944,7 +946,8 @@ def create_new_client(self, give_focus=True, filename=''):
additional_options=self.additional_options(),
interpreter_versions=self.interpreter_versions(),
connection_file=cf,
menu_actions=self.menu_actions)
menu_actions=self.menu_actions,
stderr_dir=stderr_dir)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead of doing this, please change it to

if self.testing:
    client.stderr_dir = self.test_dir

@@ -95,7 +95,8 @@ def __init__(self, plugin, id_,
additional_options, interpreter_versions,
connection_file=None, hostname=None,
menu_actions=None, slave=False,
external_kernel=False, given_name=None):
external_kernel=False, given_name=None,
stderr_dir=TEMPDIR):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please remove this

@@ -113,6 +114,7 @@ def __init__(self, plugin, id_,
self.stop_icon = ima.icon('stop')
self.history = []
self.allow_rename = True
self.stderr_dir = stderr_dir
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This needs to be

# Used only for testing
self.stderr_dir = None

@@ -163,7 +165,7 @@ def stderr_file(self):
"""Filename to save kernel stderr output."""
if self.connection_file is not None:
stderr_file = self.kernel_id + '.stderr'
stderr_file = osp.join(TEMPDIR, stderr_file)
stderr_file = osp.join(self.stderr_dir, stderr_file)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Finally, this needs to be

if self.stderr_dir is not None:
    stderr_file = osp.join(self.stderr_dir, stderr_file)
else:
    stderr_file = osp.join(TEMPDIR, stderr_file)

@ccordoba12 ccordoba12 changed the title PR: Add test with non-ascii directory for stderr file PR: Add test with non-ascii directory for consoles stderr file Aug 28, 2017
@ccordoba12 ccordoba12 merged commit 8efe647 into spyder-ide:3.x Aug 28, 2017
ccordoba12 added a commit that referenced this pull request Aug 28, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants