-
-
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 test with non-ascii directory for consoles stderr file #5013
Conversation
@ccordoba12 should I do something else with this one? |
spyder/plugins/ipythonconsole.py
Outdated
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'اختبار')) |
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.
@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) |
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 also find a solution similar to the one I posted above to avoid putting this temp directory as part of our source code.
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): |
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.
@dalthviz, are you sure we need an extra fixture for this? Is it not possible to add an extra parameter to the previous fixture?
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, you are right 👍 no need of a extra fixture
spyder/plugins/ipythonconsole.py
Outdated
@@ -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): |
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 here only TEMPDIR
, so import it from programs
with
from programs import TEMPDIR
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 also need to add
self.test_dir = test_dir
spyder/plugins/ipythonconsole.py
Outdated
@@ -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): |
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 don't add a new parameter here because we'd need to also add new Slot
's
spyder/plugins/ipythonconsole.py
Outdated
@@ -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) |
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.
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): |
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 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 |
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.
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) |
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.
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)
Fixes #4836