1414from 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+
1725def test_table2string ():
1826 assert_equal (table2string ([["A" , "B" , "C" , "D" ], ["E" , "F" , "G" , "H" ]]), "A B C D\n E 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
2432def 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