Jul-12-2020, 07:51 PM
I am using VSCode for Python programming.
I have two files:
(1) pyMain
(2) pyTests
With this program I am learning to write unit tests using pyTest.
[pyMain.py]
[pyTests.py]
I have two files:
(1) pyMain
(2) pyTests
With this program I am learning to write unit tests using pyTest.
[pyMain.py]
class Mathematics: def AddNum(self,num1,num2): return num1+num2 def SubtractNum(self,num1,num2): return num1-num2
[pyTests.py]
from pyMain import Mathematics import pytest def TestAddition(): assert Mathematics.AddNum(1,5,6) == 11 def TestSubtraction(): assert Mathematics.SubtractNum(1,6,3) == 3 TestAddition() TestSubtraction()I am not understanding why there is a need to pass value for 'self' in functions AddNum and SubtractNum. In pyTests.py, I am passing '1' to prevent error in the assert statements.