To test your test() method you should create a test file like this
import unittest
from your_file import test
class TestMethodTestCase(unittest.TestCase):
def test_01a(self):
""" test the test method"""
self.failUnlessEqual(9, test(a=4, b=2)) # here you write all the use case you need to be sure that your method is correctly doing the job
self.failUnlessEqual(10, test(a=1, b=2))
self.failUnlessEqual(11, test(a=5, b=3))
if __name__=="__main__":
unittest.main()
with your test() method defined like this :
def test(a=1, b=2):
c = a + 2
if c > 5:
z = 7
else:
z = 8
answer = b + z
return answer
Have a look to python unittest documentation
test(a, b)). In that case you'd try it with several different arguments and check that it returns the expected value in all cases.