From 393b2393a5a5effcc325cfeb92e5222c99f750f2 Mon Sep 17 00:00:00 2001 From: Mike Naberezny Date: Fri, 3 Feb 2012 20:25:55 -0800 Subject: [PATCH] Show help when cd is not given an argument --- src/py65/monitor.py | 3 +++ src/py65/tests/test_monitor.py | 8 ++++++++ 2 files changed, 11 insertions(+) diff --git a/src/py65/monitor.py b/src/py65/monitor.py index 1c4b9ed..fa6bc92 100644 --- a/src/py65/monitor.py +++ b/src/py65/monitor.py @@ -457,6 +457,9 @@ class Monitor(cmd.Cmd): self._output("Change the working directory.") def do_cd(self, args): + if args == '': + return self.help_cd() + try: os.chdir(args) except OSError, why: diff --git a/src/py65/tests/test_monitor.py b/src/py65/tests/test_monitor.py index 961afa8..0591e8d 100644 --- a/src/py65/tests/test_monitor.py +++ b/src/py65/tests/test_monitor.py @@ -149,6 +149,14 @@ class MonitorTests(unittest.TestCase): out = stdout.getvalue() self.assertTrue(out.startswith("cd ")) + def test_do_cd_with_no_dir_shows_help(self): + stdout = StringIO() + mon = Monitor(stdout=stdout) + mon.do_cd("") + + out = stdout.getvalue() + self.assertTrue(out.startswith("cd ")) + # delete_label def test_shortcut_for_delete_label(self):