Source

chop_code_Kata / tests.py

Full commit
import unittest


class TestChopper(unittest.TestCase):

    def chop_kata_moves(self,chop):



        self.assertEqual(-1, chop(3, []))
        self.assertEqual(-1, chop(3, [1]))
        self.assertEqual(0,  chop(1, [1]))


        self.assertEqual(0,  chop(1, [1, 3, 5]))
        self.assertEqual(1,  chop(3, [1, 3, 5]))
        self.assertEqual(2,  chop(5, [1, 3, 5]))
        self.assertEqual(-1, chop(0, [1, 3, 5]))
        self.assertEqual(-1, chop(2, [1, 3, 5]))
        self.assertEqual(-1, chop(4, [1, 3, 5]))
        self.assertEqual(-1, chop(6, [1, 3, 5]))

        self.assertEqual(0,  chop(1, [1, 3, 5, 7]))
        self.assertEqual(1,  chop(3, [1, 3, 5, 7]))
        self.assertEqual(2,  chop(5, [1, 3, 5, 7]))
        self.assertEqual(3,  chop(7, [1, 3, 5, 7]))
        self.assertEqual(-1, chop(0, [1, 3, 5, 7]))
        self.assertEqual(-1, chop(2, [1, 3, 5, 7]))
        self.assertEqual(-1, chop(4, [1, 3, 5, 7]))
        self.assertEqual(-1, chop(6, [1, 3, 5, 7]))
        self.assertEqual(-1, chop(8, [1, 3, 5, 7]))

    def test_chop_one(self):
        from one.chopper import chop as chop_one
        self.chop_kata_moves(chop_one)

    def test_chop_two(self):
        from two.chopper import chop as chop_two
        self.chop_kata_moves(chop_two)

    def test_chop_three(self):
        from three.chopper import chop as chop_three
        self.chop_kata_moves(chop_three)
 
    def test_chop_four(self):
        from four.chopper import chop as chop_four
        self.chop_kata_moves(chop_four)

		
    def test_chop_five(self):
        from five.chopper import chop as chop_five
        self.chop_kata_moves(chop_five)	


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