Skip to content

Commit 2f0db4d

Browse files
committed
Merge pull request #56 from MarcCote/fix_empty_command
Fixed issue #54
2 parents a06cdc3 + 1ee6c4a commit 2f0db4d

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed

smartdispatch/smartdispatch.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ def get_commands_from_file(fileobj):
9595
commands : list of str
9696
commands read from the file
9797
'''
98-
return fileobj.read().split('\n')
98+
return fileobj.read().strip().split('\n')
9999

100100

101101
def get_commands_from_arguments(arguments):

smartdispatch/tests/test_smartdispatch.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,10 @@ def test_get_commands_from_file():
7272
fileobj = StringIO("\n".join(commands))
7373
assert_array_equal(smartdispatch.get_commands_from_file(fileobj), commands)
7474

75+
# Test stripping last line if empty
76+
fileobj = StringIO("\n".join(commands) + "\n")
77+
assert_array_equal(smartdispatch.get_commands_from_file(fileobj), commands)
78+
7579

7680
def test_get_commands_from_arguments():
7781
# Test single unfolded arguments

0 commit comments

Comments
 (0)