Skip to content

Commit 6950607

Browse files
committed
added test for ap() and made changes re Travis CI
1 parent 9441bca commit 6950607

File tree

2 files changed

+13
-5
lines changed

2 files changed

+13
-5
lines changed

nibabel/cmdline/tests/test_utils.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,3 +19,11 @@ def test_table2string():
1919
assert_equal(table2string([["Let's", "Make", "Tests", "And"], ["Have", "Lots", "Of", "Fun"],
2020
["With", "Python", "Guys", "!"]]), "Let's Make Tests And\n Have Lots Of Fun"+
2121
"\n With Python Guys !\n")
22+
23+
24+
def test_ap():
25+
assert_equal(ap([1, 2], "%2d"), " 1, 2")
26+
assert_equal(ap([1, 2], "%3d"), " 1, 2")
27+
assert_equal(ap([1, 2], "%-2d"), "1 , 2 ")
28+
assert_equal(ap([1, 2], "%d", "+"), "1+2")
29+
assert_equal(ap([1, 2, 3], "%d", "-"), "1-2-3")

nibabel/cmdline/utils.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -108,11 +108,11 @@ def table2string(table, out=None):
108108
return value
109109

110110

111-
def ap(l, format_, sep=', '):
111+
def ap(helplist, format_, sep=', '):
112112
"""Little helper to enforce consistency"""
113-
if l == '-':
114-
return l
115-
ls = [format_ % x for x in l]
113+
if helplist == '-':
114+
return helplist
115+
ls = [format_ % x for x in helplist]
116116
return sep.join(ls)
117117

118118

@@ -124,4 +124,4 @@ def safe_get(obj, name):
124124
return f()
125125
except Exception as e:
126126
verbose(2, "get_%s() failed -- %s" % (name, e))
127-
return '-'
127+
return '-'

0 commit comments

Comments
 (0)