I am very new to Unit Testing in Python. I was writing a unit test for a very small method. The code implementation is a follows. But if I run the test script, I get an error saying :
TypeError:
__init__()missing 4 required positional arguments: 'x ,'y','z','w'
class get_result():
def __init__(self,x,y,z,w):
self.x=x
self.y=y
self.z=z
self.w=w
def generate_result(self):
curr_x= 90
dist= curr_x-self.x
return dist
import unittest
from sample import get_result
result = get_result()
class Test(unittest.TestCase):
def test_generate_result(self):
self.assertEqual(somevalue, result.generate_result())
def __init__(self,x=0,y=0,z=0,w=0):to define default values if you don't want to pass any arguments.