Suppose you have a fix for the following delta function:
Broken Version:
def delta(a, b): return a - b
Fixed Version:
def delta(a, b): return abs(a - b)
Then specify the following test file. It will fail with a broken version and work with a fixed version.
import unittest from module_you_fixed import delta class TestDelta(unittest.TestCase): def test_delta(self): self.assertEqual(delta(9, 7), 2) self.assertEqual(delta(2, 5), 3) if __name__ == '__main__': unittest.main()
I assumed that the project uses the standard unittest module of the library. You must use the structure used by the project.
source share