Trying to build an unittest in Python, but I get this TypeError where it says that it misses required potential argument. I've tried everything and end up with this code here:
import unittest
from MyCosine import CosineSim, CosineDis
class TestMyCosine(unittest.TestCase):
x = [3.5 , 3 , 3.5 , 2.5 , 3]
y = [3.5 , 3 , 4 , 2.5 , 4.5]
result = 0.9865867
def testCosineSim(self, result, x, y):
self.x = x
self.y = y
self.result = result
self.assertEqual(CosineSim(x,y), result, "0.9865867" )
def testCosineDis(self, result, x, y):
self.x = x
self.y = y
self.result = result
self.assertEqual(CosineDis(x,y) , result, "0.9865867")
if __name__ == '__main__':
unittest.main(exit=False)
and this is the error message:
======================================================================
ERROR: testCosineDis (__main__.TestMyCosine)
----------------------------------------------------------------------
TypeError: testCosineDis() missing 3 required positional arguments: 'result', 'x', and 'y'
======================================================================
ERROR: testCosineSim (__main__.TestMyCosine)
----------------------------------------------------------------------
TypeError: testCosineSim() missing 3 required positional arguments: 'result', 'x', and 'y'
----------------------------------------------------------------------
Ran 2 tests in 0.000s
FAILED (errors=2)
This is one of the actual functions:
def CosineDis(x,y):
result = 1 - distance.cosine(x, y)
return result