1

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.

1 Answer 1

2

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].

Sign up to request clarification or add additional context in comments.

1 Comment

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() ?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.