Skip to content

Commit

Permalink
Merge pull request #64 from rolobio/coverage-fix
Browse files Browse the repository at this point in the history
Coverage fix
  • Loading branch information
rolobio committed Apr 8, 2015
2 parents 90d1675 + e8eddfc commit c0ada92
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
9 changes: 4 additions & 5 deletions sshm/lib.py
Expand Up @@ -25,21 +25,20 @@ def expand_ranges(to_expand):
@type to_expand: str
"""
if to_expand == '-':
return [str(i) for i in range(0, 256)]
for i in range(0, 256):
yield str(i)

nums = []
for single, range_str in _match_ranges.findall(to_expand):
if single:
nums.append(single)
yield single
if range_str:
i, j = range_str.split('-')
# Create a string that will pad the integer with its current amount
# of zeroes.
# Example: if i is '03' the string will be '%0.2d'
padding = '%'+'0.%d' % len(i) +'d'
for k in range(int(i), int(j)+1):
nums.append(padding % k)
return nums
yield padding % k


def create_uri(user, target, port):
Expand Down
5 changes: 3 additions & 2 deletions sshm/test/test_lib.py
Expand Up @@ -98,7 +98,7 @@ def test_expand_ranges(self):
]

for range_str, expected in tests:
output = lib.expand_ranges(range_str)
output = list(lib.expand_ranges(range_str))
self.assertEqual(expected, output)


Expand Down Expand Up @@ -290,7 +290,8 @@ def test_triple(self):
self.addCleanup(setattr, lib, 'popen', lib.popen)
lib.popen = sub.popen

results_list = list(lib.sshm('example[01-03].com', 'exit'))
results_list = list(lib.sshm(['example01.com', 'example[02-03].com'],
'exit'))
self.assertEqual(3, len(results_list))
self.assertEqual(3,
len(set([r['uri'] for r in results_list]))
Expand Down

0 comments on commit c0ada92

Please sign in to comment.