lundi 11 juillet 2016

How to unit test Python programs in PyCharm

I am wondering how to use unit testing in PyCharm. I read:

but I couldn't really understand how to implement and test programs using unit testing.

I have written a basic addition code:

math.py

class math:
    def addition(a, b):
        return a+b

print(addition(10, 20))

I highlighted math and pressed Ctrl+Shift+T to create a test case where it took me to another file with the following code

test_math.py

from unittest import TestCase


class TestMath(TestCase):
    def test_addition(self):
        self.fail()

I have no idea how to test my addition function or pass any value as a parameter.

Aucun commentaire:

Enregistrer un commentaire