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

Fix #11527 initialize posix aliases after a %reset #11528

Merged
merged 1 commit into from Jan 6, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
7 changes: 7 additions & 0 deletions IPython/core/interactiveshell.py
Expand Up @@ -1433,6 +1433,13 @@ def reset(self, new_session=True):
self.alias_manager.clear_aliases()
self.alias_manager.init_aliases()

# Now define aliases that only make sense on the terminal, because they
# need direct access to the console in a way that we can't emulate in
# GUI or web frontend
if os.name == 'posix':
for cmd in ('clear', 'more', 'less', 'man'):
self.alias_manager.soft_define_alias(cmd, cmd)

# Flush the private list of module references kept for script
# execution protection
self.clear_main_mod_cache()
Expand Down
10 changes: 10 additions & 0 deletions IPython/core/tests/test_interactiveshell.py
Expand Up @@ -495,6 +495,16 @@ def test_last_execution_result(self):
self.assertFalse(ip.last_execution_result.success)
self.assertIsInstance(ip.last_execution_result.error_in_exec, NameError)

def test_reset_aliasing(self):
""" Check that standard posix aliases work after %reset. """
if os.name != 'posix':
return

ip.reset()
for cmd in ('clear', 'more', 'less', 'man'):
res = ip.run_cell('%' + cmd)
self.assertEqual(res.success, True)


class TestSafeExecfileNonAsciiPath(unittest.TestCase):

Expand Down
2 changes: 1 addition & 1 deletion IPython/terminal/interactiveshell.py
Expand Up @@ -447,7 +447,7 @@ def init_alias(self):
# need direct access to the console in a way that we can't emulate in
# GUI or web frontend
if os.name == 'posix':
for cmd in ['clear', 'more', 'less', 'man']:
for cmd in ('clear', 'more', 'less', 'man'):
self.alias_manager.soft_define_alias(cmd, cmd)


Expand Down