Skip to content

Commit 8e7ade3

Browse files
committed
fixed ap test problem but TypeError from nose popped up
1 parent 6950607 commit 8e7ade3

File tree

1 file changed

+16
-3
lines changed

1 file changed

+16
-3
lines changed

nibabel/cmdline/tests/test_utils.py

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,14 @@
1414
from nibabel.cmdline.utils import *
1515

1616

17+
class TestObject:
18+
def __init__(self, test):
19+
self.test = test
20+
21+
def get_test(self):
22+
return self.test
23+
24+
1725
def test_table2string():
1826
assert_equal(table2string([["A", "B", "C", "D"], ["E", "F", "G", "H"]]), "A B C D\nE F G H\n")
1927
assert_equal(table2string([["Let's", "Make", "Tests", "And"], ["Have", "Lots", "Of", "Fun"],
@@ -22,8 +30,13 @@ def test_table2string():
2230

2331

2432
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 ")
33+
assert_equal(ap([1, 2], "%2d"), " 1, 2")
34+
assert_equal(ap([1, 2], "%3d"), " 1, 2")
35+
assert_equal(ap([1, 2], "%-2d"), "1 , 2 ")
2836
assert_equal(ap([1, 2], "%d", "+"), "1+2")
2937
assert_equal(ap([1, 2, 3], "%d", "-"), "1-2-3")
38+
39+
40+
def test_safe_get():
41+
assert_equal(safe_get(TestObject(2), "test"), 2)
42+
assert_equal(safe_get(TestObject(2), "failtest"), "-")

0 commit comments

Comments
 (0)