MarkTransell/masterscode — Issue #3: Write your tests as tests
Author: alchemyst
Created: 2012-02-09 18:31:20+00:00
State: open

It's really as simple as taking code like this:

def myfunc(a, b):
return a + b

print myfunc(2, 3) # check the output to see if the answer is right

to rather be this:

import unittest

class test(unittest.TestCase):
def testmyfunc(self):
self.assertEqual(myfunc(1,2), 3)

def myfunc(a, b):
return a+b

if __name__=="__main__":
unittest.main()