0

I have a python function somefunc(), that must return an array like this [1, 2, 3]. Now I'm writing a unittest to check what this functions return:

class TestingFunctionsTest(unittest.TestCase):
    def test_somefunc(self):
        #what to write here ?

I'm new in python testing, please help.

Martijn Pieters
  • 1,048,767
  • 296
  • 4,058
  • 3,343
user3057314
  • 65
  • 1
  • 7

1 Answers1

1

You can write:

from mymodule import somefunc

class TestingFunctionsTest(unittest.TestCase):
    def test_somefunc(self):
        self.assertEqual(somefunc(), [1, 2, 3])

This calls the function and asserts that the return value must be equal to [1, 2, 3].

Simeon Visser
  • 118,920
  • 18
  • 185
  • 180
  • Thanks very much, can you plz tell how to check if the function returns integer for example ? Or, if you can, give some link with instructions how to use assertEqual() ? – user3057314 Dec 09 '13 at 12:01