55"""
66
77import unittest
8- from fib import fib
8+ from utility . fibonacci import fib
99
1010
1111class FibTest (unittest .TestCase ):
1212 # optional - executes before each test function
1313 def setUp (self ):
14- self .fibSeq = [(1 , 1 ), (2 , 1 ), (3 , 2 ), (10 , 55 ), (20 , 6765 )]
14+ self .fib_seq = [(1 , 1 ), (2 , 1 ), (3 , 2 ), (10 , 55 ), (20 , 6765 )]
1515 print ('setUp executed...' )
1616
1717 # any function that start with test* will be executed automatically
1818 def test1 (self ):
19- print ('test1' )
2019 # assertEqual is defined in TestCase class
21- for n , val in self .fibSeq :
20+ for n , val in self .fib_seq :
2221 self .assertEqual (fib (n ), val )
2322
2423 def test2 (self ):
25- print ('test2' )
2624 # function name can be arbitrary but must start with test or
2725 # should be runTest
2826 self .assertEqual (fib (1 ), 1 )
2927 self .assertEqual (fib (10 ), 55 )
3028 self .assertEqual (fib (20 ), 6765 )
3129
3230 def test3 (self ):
33- print ('test3' )
3431 # doesn't test fib function but gets called...
3532 self .assertAlmostEqual (22 / 7 , 3.142857 , 6 )
3633 # uncomment the following and run it
@@ -51,8 +48,3 @@ def someTest(self):
5148 def tearDown (self ):
5249 self .fibElems = None
5350 print ("tearDown executed..." )
54-
55-
56- if __name__ == "__main__" :
57- # auto-discover unittest in this module and run it...
58- unittest .main ()
0 commit comments