Skip to content

Commit 20d2abb

Browse files
authored
Merge pull request #758 from python-cmd2/empty_script_ok
No longer treating empty text scripts as an error condition
2 parents e1cde42 + 1bbf27f commit 20d2abb

File tree

3 files changed

+6
-3
lines changed

3 files changed

+6
-3
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
## 0.9.17 (TBD, 2019)
2+
* Enhancements
3+
* No longer treating empty text scripts as an error condition
4+
15
## 0.9.16 (August 7, 2019)
26
* Bug Fixes
37
* Fixed inconsistent parsing/tab completion behavior based on the value of `allow_redirection`. This flag is

cmd2/cmd2.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3790,9 +3790,8 @@ def do_run_script(self, args: argparse.Namespace) -> Optional[bool]:
37903790
self.perror("'{}' is not a file".format(expanded_path))
37913791
return
37923792

3793-
# Make sure the file is not empty
3793+
# An empty file is not an error, so just return
37943794
if os.path.getsize(expanded_path) == 0:
3795-
self.perror("'{}' is empty".format(expanded_path))
37963795
return
37973796

37983797
# Make sure the file is ASCII or UTF-8 encoded text

tests/test_cmd2.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -318,7 +318,7 @@ def test_run_script_with_empty_file(base_app, request):
318318
test_dir = os.path.dirname(request.module.__file__)
319319
filename = os.path.join(test_dir, 'scripts', 'empty.txt')
320320
out, err = run_cmd(base_app, 'run_script {}'.format(filename))
321-
assert "is empty" in err[0]
321+
assert not out and not err
322322

323323
def test_run_script_with_binary_file(base_app, request):
324324
test_dir = os.path.dirname(request.module.__file__)

0 commit comments

Comments
 (0)