From c4d7833dd3fb170fb95fa17e4e0336235e4e0ba3 Mon Sep 17 00:00:00 2001 From: Kevin Van Brunt Date: Thu, 8 Aug 2019 22:02:47 -0400 Subject: [PATCH 1/2] No longer treating empty text scripts as an error condition --- cmd2/cmd2.py | 3 +-- tests/test_cmd2.py | 2 +- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/cmd2/cmd2.py b/cmd2/cmd2.py index a0df0b00e..9d29418b9 100755 --- a/cmd2/cmd2.py +++ b/cmd2/cmd2.py @@ -3790,9 +3790,8 @@ def do_run_script(self, args: argparse.Namespace) -> Optional[bool]: self.perror("'{}' is not a file".format(expanded_path)) return - # Make sure the file is not empty + # An empty file is not an error, so just return if os.path.getsize(expanded_path) == 0: - self.perror("'{}' is empty".format(expanded_path)) return # Make sure the file is ASCII or UTF-8 encoded text diff --git a/tests/test_cmd2.py b/tests/test_cmd2.py index a856c1d6b..313b4dee6 100755 --- a/tests/test_cmd2.py +++ b/tests/test_cmd2.py @@ -318,7 +318,7 @@ def test_run_script_with_empty_file(base_app, request): test_dir = os.path.dirname(request.module.__file__) filename = os.path.join(test_dir, 'scripts', 'empty.txt') out, err = run_cmd(base_app, 'run_script {}'.format(filename)) - assert "is empty" in err[0] + assert not out and not err def test_run_script_with_binary_file(base_app, request): test_dir = os.path.dirname(request.module.__file__) From 1bbf27fbd10848542940d5657e653f60969ed1c5 Mon Sep 17 00:00:00 2001 From: Kevin Van Brunt Date: Thu, 8 Aug 2019 22:23:17 -0400 Subject: [PATCH 2/2] Updated change log --- CHANGELOG.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index ce18aacc4..6d6a7d125 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,7 @@ +## 0.9.17 (TBD, 2019) +* Enhancements + * No longer treating empty text scripts as an error condition + ## 0.9.16 (August 7, 2019) * Bug Fixes * Fixed inconsistent parsing/tab completion behavior based on the value of `allow_redirection`. This flag is