14
14
from nibabel .cmdline .utils import *
15
15
16
16
17
+ class TestObject :
18
+ def __init__ (self , test ):
19
+ self .test = test
20
+
21
+ def get_test (self ):
22
+ return self .test
23
+
24
+
17
25
def test_table2string ():
18
26
assert_equal (table2string ([["A" , "B" , "C" , "D" ], ["E" , "F" , "G" , "H" ]]), "A B C D\n E F G H\n " )
19
27
assert_equal (table2string ([["Let's" , "Make" , "Tests" , "And" ], ["Have" , "Lots" , "Of" , "Fun" ],
@@ -22,8 +30,13 @@ def test_table2string():
22
30
23
31
24
32
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 " )
28
36
assert_equal (ap ([1 , 2 ], "%d" , "+" ), "1+2" )
29
37
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